|
@@ -24,7 +24,6 @@ var SortDocumentSource = module.exports = function SortDocumentSource(ctx){
|
|
|
* on the first call to any method on this source. The populated
|
|
* on the first call to any method on this source. The populated
|
|
|
* boolean indicates that this has been done
|
|
* boolean indicates that this has been done
|
|
|
**/
|
|
**/
|
|
|
- // TODO clean these up
|
|
|
|
|
this.populated = false;
|
|
this.populated = false;
|
|
|
this.docIterator = null; // a number tracking our position in the documents array
|
|
this.docIterator = null; // a number tracking our position in the documents array
|
|
|
this.documents = []; // an array of documents
|
|
this.documents = []; // an array of documents
|
|
@@ -70,8 +69,10 @@ proto.getDependencies = function getDependencies(deps) {
|
|
|
|
|
|
|
|
proto.coalesce = function coalesce(nextSource) {
|
|
proto.coalesce = function coalesce(nextSource) {
|
|
|
if (!this.limitSrc) {
|
|
if (!this.limitSrc) {
|
|
|
- if (nextSource instanceof LimitDocumentSource)
|
|
|
|
|
|
|
+ if (nextSource instanceof LimitDocumentSource) {
|
|
|
|
|
+ this.limitSrc = nextSource;
|
|
|
return nextSource;
|
|
return nextSource;
|
|
|
|
|
+ }
|
|
|
return false;
|
|
return false;
|
|
|
} else {
|
|
} else {
|
|
|
return this.limitSrc.coalesce(nextSource);
|
|
return this.limitSrc.coalesce(nextSource);
|
|
@@ -108,7 +109,7 @@ proto.serializeToArray = function serializeToArray(array, explain) {
|
|
|
if (explain) {
|
|
if (explain) {
|
|
|
doc.sortKey = this.serializeSortKey();
|
|
doc.sortKey = this.serializeSortKey();
|
|
|
doc.mergePresorted = this._mergePresorted;
|
|
doc.mergePresorted = this._mergePresorted;
|
|
|
- doc.limit = this.limitSrc ? this.limitSrc.getLimit() : null;
|
|
|
|
|
|
|
+ doc.limit = this.limitSrc ? this.limitSrc.getLimit() : undefined;
|
|
|
array.push(doc);
|
|
array.push(doc);
|
|
|
} else {
|
|
} else {
|
|
|
var inner = this.serializeSortKey();
|
|
var inner = this.serializeSortKey();
|
|
@@ -141,7 +142,7 @@ proto.addKey = function addKey(fieldPath, ascending) {
|
|
|
if (ascending === true || ascending === false) {
|
|
if (ascending === true || ascending === false) {
|
|
|
this.vAscending.push(ascending);
|
|
this.vAscending.push(ascending);
|
|
|
} else {
|
|
} else {
|
|
|
- // TODO: This doesn't appear to be an error?
|
|
|
|
|
|
|
+ // This doesn't appear to be an error in real mongo?
|
|
|
throw new Error("ascending must be true or false");
|
|
throw new Error("ascending must be true or false");
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -263,3 +264,5 @@ klass.createFromJson = function createFromJson(jsonElement, ctx) {
|
|
|
if (sortKeys <= 0) throw new Error("code 15976; " + klass.sortName + " must have at least one sort key");
|
|
if (sortKeys <= 0) throw new Error("code 15976; " + klass.sortName + " must have at least one sort key");
|
|
|
return nextSort;
|
|
return nextSort;
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+// makeSortOptions
|