mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Make find(1) and find({_id: 1}) return the same thing.
This commit is contained in:
@@ -70,9 +70,9 @@ LocalCollection.Cursor = function (collection, selector, options) {
|
||||
} else {
|
||||
this.selector_f = LocalCollection._compileSelector(selector);
|
||||
this.sort_f = options.sort ? LocalCollection._compileSort(options.sort) : null;
|
||||
this.skip = options.skip;
|
||||
this.limit = options.limit;
|
||||
}
|
||||
this.skip = options.skip;
|
||||
this.limit = options.limit;
|
||||
|
||||
// db_objects is a list of the objects that match the cursor. (It's always a
|
||||
// list, never an object: LocalCollection.Cursor is always ordered.)
|
||||
@@ -260,6 +260,12 @@ LocalCollection.Cursor.prototype._getRawObjects = function (ordered) {
|
||||
|
||||
// fast path for single ID value
|
||||
if (self.selector_id) {
|
||||
// If you have non-zero skip and ask for a single id, you get
|
||||
// nothing. This is so it matches the behavior of the '{_id: foo}'
|
||||
// path.
|
||||
if (self.skip)
|
||||
return results;
|
||||
|
||||
if (_.has(self.collection.docs, self.selector_id)) {
|
||||
var selectedDoc = self.collection.docs[self.selector_id];
|
||||
if (ordered)
|
||||
|
||||
@@ -124,6 +124,8 @@ Tinytest.add("minimongo - basics", function (test) {
|
||||
test.equal(c.find("abc").count(), 0);
|
||||
test.equal(c.find(undefined).count(), 0);
|
||||
test.equal(c.find().count(), 3);
|
||||
test.equal(c.find(1, {skip: 1}).count(), 0);
|
||||
test.equal(c.find({_id: 1}, {skip: 1}).count(), 0);
|
||||
|
||||
// Regression test for #455.
|
||||
c.insert({foo: {bar: 'baz'}});
|
||||
|
||||
Reference in New Issue
Block a user