Open
Description
Problem
It seems deleteMany
never deletes anything.
Indeed, it's algorithm is:
- fetch all documents matching the query with a cursor
- extract their ids
- remove the documents in the collection with these ids.
Unfortunately
- the ids are compared using
lodash.includes
which usesSameValueZero
:Line 132 in 80fdc61
- but the cursor returns cloned documents:
Line 52 in 80fdc61
- with cloned ObjectIds:
Lines 256 to 258 in 80fdc61
- with cloned ObjectIds:
This means ids never match (because they are not the same instance of ObjectId
s), and nothing is ever deleted.
Possible fix
A solution could be to add a secret option to cursor to avoid cloning documents. To use only with deleteMany
.
Activity