var Pipeline = module.exports = (function(){ // CONSTRUCTOR var klass = function Pipeline(){ this.sourceVector = [];//should be provate? }, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); var LimitDocumentSource = require('./documentSources/LimitDocumentSource'), MatchDocumentSource = require('./documentSources/MatchDocumentSource'), ProjectDocumentSource = require('./documentSources/ProjectDocumentSource'); // GroupDocumentSource = require('./documentSources/GroupDocumentSource'), // SkipDocumentSource = require('./documentSources/SkipDocumentSource'), // SortDocumentSource = require('./documentSources/SortDocumentSource'), // UnwindDocumentSource = require('./documentSources/UnwindDocumentSource'); klass.StageDesc = {};//attaching this to the class for test cases klass.StageDesc[LimitDocumentSource.limitName] = LimitDocumentSource.createFromJson; klass.StageDesc[MatchDocumentSource.matchName] = MatchDocumentSource.createFromJson; klass.StageDesc[ProjectDocumentSource.projectName] = ProjectDocumentSource.createFromJson; // klass.StageDesc[GroupDocumentSource.groupName] = GroupDocumentSource.createFromJson; // klass.StageDesc[SkipDocumentSource.skipName] = SkipDocumentSource.createFromJson; // klass.StageDesc[SortDocumentSource.sortName] = SortDocumentSource.createFromJson; // klass.StageDesc[UnwindDocumentSource.unwindName] = UnwindDocumentSource.createFromJson; /** * Create a pipeline from the command. * * @param {Object} cmdObj the command object sent from the client * @returns {Array} the pipeline, if created, otherwise a NULL reference **/ klass.parseCommand = function parseCommand(cmdObj){ var pipelineInstance = new Pipeline(), pipeline = cmdObj;//munge: skipping the command parsing since all we care about is the pipeline var sourceVector = pipelineInstance.sourceVector, nSteps = pipeline.length; for( var iStep = 0; iStep