Skip to content

Commit

Permalink
fixed; use populate filters on single OIDs too
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Oct 5, 2011
1 parent 3f4c26f commit 479ec62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/model.js
Expand Up @@ -144,7 +144,9 @@ Model.prototype._populate = function populate (schema, oid, options, fn) {
fn(null, oid);
}
} else {
this.model(schema.options.ref).findById(oid, options.fields, fn)
options.filters || (options.filters = {});
options.filters._id = oid;
this.model(schema.options.ref).findOne(options.filters, options.fields, fn)
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/model.ref.test.js
Expand Up @@ -99,7 +99,7 @@ module.exports = {
var origFind = User.findById;

// mock an error
User.findById = function () {
User.findOne = function () {
var args = Array.prototype.map.call(arguments, function (arg) {
return 'function' == typeof arg ? function () {
arg(new Error('woot'));
Expand Down

0 comments on commit 479ec62

Please sign in to comment.