The correct thing to do is to grab _id from the cloned object, because this one is the resolved selector in case of non-obvious queries. It doesn't break existing code, because in case of queries without _id (obvious or not) a new ObjectID is created, falling back to current behavior.
In the case the query look like this:
The field
id
is not obviously apparent in the selector object, hence the following line failing by producing a new ObjectID each time:(https://github.com/williamkapke/mongo-mock/blob/master/lib/collection.js#L449)
The correct thing to do is to grab
_id
from the cloned object, because this one is the resolved selector in case of non-obvious queries. It doesn't break existing code, because in case of queries without_id
(obvious or not) a new ObjectID is created, falling back to current behavior.Note: This PR depends on #114.