Skip to content

Problem Using findOne #2

@bailey-zz

Description

@bailey-zz

I've noticed that there may be an issue with the 'findOne' implementation when searching for objectIds.

If I execute the following code with a known document id as testId (i.e. 4c2b920f7b78cb5b12dea3fc), I receive a null value on return:

var c = testCol.findOne({ _id : objectId(testId) });

I wrote a similar 'findOne' function called 'findSingle' which is based on the 'find' implementation. When I pass it the same parameters as the 'findOne' call, I receive the expected document on return:

findSingle: function() {
var args = Array.prototype.slice.call(arguments)
.map(function(arg) {
return typeof arg == "object" ?
Support.createBDObject(arg) : arg;
});
return this.collection.findOne.apply(this.collection, args);
}

var c = testCol.findSingle({ _id : objectId(testId) });

Is this an issue with the 'findOne' implementation or am I using it incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions