Comments on keys sorting.

Suggested by Glasser.
This commit is contained in:
Slava Kim
2013-09-16 11:04:08 -07:00
parent 4345fdbd4b
commit 48eea25d27

View File

@@ -1038,6 +1038,9 @@ LocalCollection._compileProjection = function (fields) {
throw MinimongoError("Projection values should be one of 1, 0, true, or false");
var _idProjection = _.isUndefined(fields._id) ? true : fields._id;
// Find the non-_id keys (_id is handled specially because it is included unless
// explicitly excluded). Sort the keys, so that our code to detect overlaps
// like 'foo' and 'foo.bar' can assume that 'foo' comes first.
var fieldsKeys = _.reject(_.keys(fields).sort(), function (key) { return key === '_id'; });
var including = null; // Unknown
var projectionRulesTree = {}; // Tree represented as nested objects