Skip to content

Embedded _id field in query does not get converted to ObjectId BSON #45

@danwdart

Description

@danwdart

This should return the right field type whether I pass in {$ne: "string"} or "string"

api-mongodb/lib/index.js

Lines 501 to 507 in fd34cd4

DataStore.prototype.castToBSON = function (obj) {
// TODO: Do we need to handle casting for all fields, or will `_id` be the only BSON specific type?
// this is starting to enter ODM land...
if (typeof obj._id === 'string' && ObjectID.isValid(obj._id) && obj._id.match(/^[a-fA-F0-9]{24}$/)) {
obj._id = ObjectID.createFromHexString(obj._id)
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions