vkarpov15 / mongoose-unique-array

Plugin to handle `save()` with `unique` in arrays
Apache License 2.0
12 stars 6 forks source link

pushing a new item to a collection and calling save gives version error #16

Closed cjroebuck closed 3 years ago

cjroebuck commented 3 years ago

Hi - just wondering, am I supposed to be able to push more items to an existing subdocument array when using this plugin?

I'm not talking about the 'caveat' mentioned, i'm just talking about loading an existing document with a few subdocuments and trying to push more (non-unique) subdocuments to the array, before calling save.

see test here: https://github.com/cjroebuck/mongoose-unique-array/commit/df104917ed9784b549adcd652c9d8df7f41f6598

It's throwing the VersionError due to all of the $nin's in the where clause of updateOne

vkarpov15 commented 3 years ago

This is a bug, fixed in v0.4.2. Thanks for the test case!