Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use MongoDB fields projection on update to reduce the memory footpints #237

Merged
merged 5 commits into from
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Collection.prototype.update = function update(criteria, values, cb) {
// Lookup records being updated and grab their ID's
// Useful for later looking up the record after an insert
// Required because options may not contain an ID
collection.find(query.criteria.where).toArray(function(err, records) {
collection.find(query.criteria.where, {_id: 1}).toArray(function(err, records) {
if(err) return cb(err);
if(!records) return cb(Errors.NotFound);

Expand Down
4 changes: 2 additions & 2 deletions test/unit/query/adapter.query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ describe('Query', function () {
var where = {
or: [{ name: { $exists: false } }, { name: { '!': 'clark' } }]
};
var expect = { $or: [ { name: { $exists: false } }, { name: { $ne: /^clark$/i } } ] };
var expect = { $or: [ { name: { $exists: false } }, { name: { $ne: 'clark' } } ] };
var Q = new Query({ where: where }, { name: 'string', age: 'integer' });
var actual = Q.criteria.where;
assert(_.isEqual(actual, expect));
});

});

});
});