|
|
@@ -44,11 +44,11 @@ proto.toProjection = function toProjection() {
|
|
|
var last = "",
|
|
|
needId = false;
|
|
|
|
|
|
- for(var it in this.fields.sort()) {
|
|
|
+ Object.keys(this.fields).sort().forEach(function (it) {
|
|
|
if (it.slice(0,3) == "_id" && (it.length == 3 || it.charAt(3) == ".")) {
|
|
|
// _id and subfields are handled specially due in part to SERVER-7502
|
|
|
needId = true;
|
|
|
- continue;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if (last !== "" && it.slice(0, last.length) === last) {
|
|
|
@@ -57,12 +57,12 @@ proto.toProjection = function toProjection() {
|
|
|
// field, the parent wouldn't be fully included. This logic relies
|
|
|
// on on set iterators going in lexicographic order so that a string
|
|
|
// is always directly before of all fields it prefixes.
|
|
|
- continue;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
last = it + ".";
|
|
|
proj[it] = 1;
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
if (needId)
|
|
|
proj._id = 1;
|
|
|
@@ -81,27 +81,27 @@ proto.toProjection = function toProjection() {
|
|
|
proto.toParsedDeps = function toParsedDeps() {
|
|
|
var doc = {};
|
|
|
|
|
|
- if(this.needWholeDocument || this.needTextScore) {
|
|
|
+ if (this.needWholeDocument || this.needTextScore) {
|
|
|
// can't use ParsedDeps in this case
|
|
|
// TODO: not sure what appropriate equivalent to boost::none is
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var last = "";
|
|
|
- for(var it in this.fields.sort()) {
|
|
|
+ Object.keys(this.fields).sort().forEach(function (it) {
|
|
|
if (last !== "" && it.slice(0, last.length) === last) {
|
|
|
// we are including a parent of *it so we don't need to include this
|
|
|
// field explicitly. In fact, due to SERVER-6527 if we included this
|
|
|
// field, the parent wouldn't be fully included. This logic relies
|
|
|
// on on set iterators going in lexicographic order so that a string
|
|
|
// is always directly before of all fields it prefixes.
|
|
|
- continue;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
last = it + ".";
|
|
|
// TODO: set nested field to true; i.e. a.b.c = true, not a = true
|
|
|
doc[it] = true;
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
return new ParsedDeps(doc);
|
|
|
};
|