This should return the right field type whether I pass in {$ne: "string"} or "string"
|
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) |
|
} |
|
} |