index.js 684 B

123456789101112131415161718192021
  1. "use strict";
  2. var DocumentSource = require('../pipeline/documentSources/DocumentSource'),
  3. Runner = require("./Runner.js"),
  4. ArrayRunner = require("./ArrayRunner.js"),
  5. DocumentSourceRunner = require("./DocumentSourceRunner.js");
  6. module.exports = {
  7. Runner: Runner,
  8. ArrayRunner: ArrayRunner,
  9. DocumentSourceRunner: DocumentSourceRunner,
  10. getRunner: function(data, queryObj, sortObj, projectionForQuery, sources){
  11. if (data && data.constructor === Array){
  12. return new ArrayRunner(data);
  13. } else if (data && data instanceof DocumentSource){
  14. return new DocumentSourceRunner(data, sources);
  15. } else {
  16. throw new Error('could not construct Runner from given data');
  17. }
  18. }
  19. };