|
|
@ -85,18 +85,16 @@ Cursor.prototype.project = function (candidates) { |
|
|
|
candidates.forEach(function (candidate) { |
|
|
|
candidates.forEach(function (candidate) { |
|
|
|
var toPush; |
|
|
|
var toPush; |
|
|
|
if (action === 1) { // pick-type projection
|
|
|
|
if (action === 1) { // pick-type projection
|
|
|
|
toPush = _.pick(candidate, keys); |
|
|
|
toPush = { $set: {} }; |
|
|
|
|
|
|
|
keys.forEach(function (k) { |
|
|
|
|
|
|
|
toPush.$set[k] = model.getDotValue(candidate, k); |
|
|
|
|
|
|
|
if (toPush.$set[k] === undefined) { delete toPush.$set[k]; } |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
toPush = model.modify({}, toPush); |
|
|
|
} else { // omit-type projection
|
|
|
|
} else { // omit-type projection
|
|
|
|
//console.log('--------------------------------------------');
|
|
|
|
|
|
|
|
//console.log(candidate);
|
|
|
|
|
|
|
|
toPush = { $unset: {} }; |
|
|
|
toPush = { $unset: {} }; |
|
|
|
keys.forEach(function (k) { toPush.$unset[k] = true }); |
|
|
|
keys.forEach(function (k) { toPush.$unset[k] = true }); |
|
|
|
|
|
|
|
|
|
|
|
//console.log(toPush);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toPush = model.modify(candidate, toPush); |
|
|
|
toPush = model.modify(candidate, toPush); |
|
|
|
|
|
|
|
|
|
|
|
//console.log(toPush);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (keepId) { |
|
|
|
if (keepId) { |
|
|
|
toPush._id = candidate._id; |
|
|
|
toPush._id = candidate._id; |
|
|
|