Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with findOneAndUpdate #11

Open
dottodot opened this issue Sep 8, 2016 · 9 comments
Open

Doesn't work with findOneAndUpdate #11

dottodot opened this issue Sep 8, 2016 · 9 comments

Comments

@dottodot
Copy link

dottodot commented Sep 8, 2016

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.

@ramiel
Copy link
Owner

ramiel commented Sep 8, 2016

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.

@linusbrolin
Copy link

linusbrolin commented Sep 21, 2016

@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.

@ramiel
Copy link
Owner

ramiel commented Sep 21, 2016

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

@linusbrolin
Copy link

Ok, I'll see if I can find some time to look at those points in the near future.

@ramiel
Copy link
Owner

ramiel commented Sep 21, 2016

Thank you. Your contribution is really appreciated!

@ptariche
Copy link

ptariche commented May 8, 2018

Any update in reference to #29, the same issue obviously occurs with bulkwrite. @ramiel

@acskck
Copy link

acskck commented May 14, 2020

The same issue is still there. Any update?

@blocks-master
Copy link

any update ?

@ramiel
Copy link
Owner

ramiel commented Aug 23, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants