mongoose-sequence
mongoose-sequence copied to clipboard
Doesn't work with findOneAndUpdate
I'm using findOneAndUpdate and upsert:true
to do a findOrCreate buy my auto increment field is not being populated. It works when using create.
There is an open PR (#10) on this problem. We still are not able to fix the problem mainly because of how mongoose hooks works for findOneAndUpdate
.
@ramiel what exactly is it that will have to be fixed before my PR can be merged?
Auto incrementation works fine in findOneAndUpdate using the code in my PR. The only "bad" thing I know of, is that it has to perform another find query in order to make it work. But until Mongoose can provide a way to avoid having to do that, I don't see another choice.
There is a list on the PR. By the way:
- Using
multi: true
during an update should work the same - The same functionality should work for
referenced fields
I prefer to release the functionality when is complete. On the other side I had no time at all to look again at this
Ok, I'll see if I can find some time to look at those points in the near future.
Thank you. Your contribution is really appreciated!
Any update in reference to #29, the same issue obviously occurs with bulkwrite. @ramiel
The same issue is still there. Any update?
any update ?
Due to the way mongoose hooks work,it's not.possible to cover all the cases. I'll should probably find the time to cover at least the basic use case (no multi,no bulkwrite) but I have no time now,so I don't know when I can work on this again