|
@@ -182,22 +182,23 @@ klass.parseCommand = function parseCommand(cmdObj, ctx){
|
|
|
* @param callback {Function} The callback function
|
|
* @param callback {Function} The callback function
|
|
|
**/
|
|
**/
|
|
|
proto.run = function run(inputSource, callback){
|
|
proto.run = function run(inputSource, callback){
|
|
|
- if(inputSource && !(inputSource instanceof DocumentSource)) throw new Error("arg `inputSource` must be an instance of DocumentSource");
|
|
|
|
|
- if(!callback) throw new Error("arg `callback` required");
|
|
|
|
|
|
|
+ if (inputSource && !(inputSource instanceof DocumentSource)) throw new Error("arg `inputSource` must be an instance of DocumentSource");
|
|
|
|
|
+ if (!callback) throw new Error("arg `callback` required");
|
|
|
var self = this;
|
|
var self = this;
|
|
|
- // chain together the sources we found
|
|
|
|
|
- var source = inputSource;
|
|
|
|
|
- async.eachSeries(self.sourceVector,
|
|
|
|
|
- function eachSrc(temp, next){
|
|
|
|
|
- temp.setSource(source, function(err){
|
|
|
|
|
- if (err) return next(err);
|
|
|
|
|
- source = temp;
|
|
|
|
|
- return next();
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- function doneSrcs(err){ //source is left pointing at the last source in the chain
|
|
|
|
|
- if (err) return callback(err);
|
|
|
|
|
- inputSource.setSource(undefined, function(err){ //TODO: HACK: temp solution to the fact that we need to initialize our source since we're using setSource as a workaround for the lack of real async cursors
|
|
|
|
|
|
|
+ inputSource.setSource(undefined, function(err){ //TODO: HACK: temp solution to the fact that we need to initialize our source since we're using setSource as a workaround for the lack of real async cursors
|
|
|
|
|
+ if (err) return callback(err);
|
|
|
|
|
+ // chain together the sources we found
|
|
|
|
|
+ var source = inputSource;
|
|
|
|
|
+ async.eachSeries(
|
|
|
|
|
+ self.sourceVector,
|
|
|
|
|
+ function eachSrc(temp, next){
|
|
|
|
|
+ temp.setSource(source, function(err){
|
|
|
|
|
+ if (err) return next(err);
|
|
|
|
|
+ source = temp;
|
|
|
|
|
+ return next();
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ function doneSrcs(err){ //source is left pointing at the last source in the chain
|
|
|
if (err) return callback(err);
|
|
if (err) return callback(err);
|
|
|
/*
|
|
/*
|
|
|
Iterate through the resulting documents, and add them to the result.
|
|
Iterate through the resulting documents, and add them to the result.
|
|
@@ -222,7 +223,7 @@ proto.run = function run(inputSource, callback){
|
|
|
// ,ok: true; //not actually in here... where does this come from?
|
|
// ,ok: true; //not actually in here... where does this come from?
|
|
|
};
|
|
};
|
|
|
return callback(null, result);
|
|
return callback(null, result);
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|