Data loss pushing items to list when sorting list and saving multiple times #12656
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
6.7.0
Node.js version
16.13.1
MongoDB server version
4.2.8
Typescript version (if applicable)
4.8.4
Description
The provided test case shows data loss pushing items to list/subcollection when sorting the subcollection AND saving multiple times.
If the
orderBy()
lines are omitted, the result is correct OR if the firstdoc.save()
is omitted, the result is correct.This test case shows data loss, but a similar flow causes duplicate items to be inserted into the array on the 2nd save.
Steps to Reproduce
Actual output. Note that the
{a: 3}
element is missing. If the firstdoc.save()
is omitted the output is correct.Expected Behavior
The result should not change if the first
doc.save()
is omitted. If this use case is not supported, then it should fail loudly.The text was updated successfully, but these errors were encountered: