mongo-mock icon indicating copy to clipboard operation
mongo-mock copied to clipboard

ObjectID differ between mongodb and mongo-mock

Open cscetbon opened this issue 6 years ago • 1 comments

I'm testing some code that uses mongodb to find/update/delete objects looking them up by their _id. However as the tested code uses require('mongodb').ObjectID and mongo-mock uses a different version of it, the tested code can't find the objects. This is really annoying ...

cscetbon avatar Mar 29 '19 00:03 cscetbon

Noticing for myself that overriding ObjectID would be valuable in that I could make it deterministic for snapshots. This ObjectID is bson-objectid, in mongodb it is mongodb-core.BSON.ObjectID

I can see theres a pkFactory in CollectionState in db.js but it's not used by create_backingstore.

Downchuck avatar Apr 14 '19 20:04 Downchuck