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

Wont work with .insertMany #7

Closed
thanhlmm opened this issue Aug 18, 2016 · 5 comments
Closed

Wont work with .insertMany #7

thanhlmm opened this issue Aug 18, 2016 · 5 comments

Comments

@thanhlmm
Copy link

Like title, it wont work with .insertMany
Can you check it out?

@ramiel
Copy link
Owner

ramiel commented Aug 22, 2016

I'll check out soon. Thank you for noticing this

@ramiel
Copy link
Owner

ramiel commented Aug 22, 2016

Looks like the hooks called during insertMany are not useful to increment the counter (you can look Automattic/mongoose#3846). I'll look if there is another way to achieve this.

@ramiel
Copy link
Owner

ramiel commented Aug 22, 2016

Meanwhile I added a test for this feature the you can find in this commit

@ramiel
Copy link
Owner

ramiel commented Aug 22, 2016

Another reference here.
Following the discussion I believe you can use .create instead. It's slower than insertMany but calls the hook. The order is not garantueed to be the same as the documents definition, as explained at Automattic/mongoose#4038.
So if you have not a lot of insertions, or performance requirements, and the order can be not guaranteed, I suggest you to use .create. Let me know.

@thanhlmm
Copy link
Author

It's a nice solution. Thank you for checking it out.
Have a nice day!

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

2 participants