-
Notifications
You must be signed in to change notification settings - Fork 51
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
Switches from drop to removeMany #31
base: master
Are you sure you want to change the base?
Conversation
What kind of errors are you seeing? |
Here's an example stack trace:
|
What are the implications of using removeMany() over drop() when it comes On Mon, Mar 21, 2016 at 1:50 PM Jan Paul Erkelens [email protected]
|
removeMany() keeps the indices intact, however, since the document is being removed the entry in the index should be removed as well and should not grow the index indefinitely. Since its common practice to clear/load your data in a beforeEach test setup, I tended to encounter this error 20-35% of the time I ran my tests. If you are running a test suite multiple times, your collection indices are unlikely to change. If you'd like to keep a command in this library that does drop collections I recommend creating a new command (drop perhaps?) that can be called at the end of the test suite. |
Just wanted to check in to make sure my last comment answered your questions. |
@jperkelens The repo owner isn't around anymore... I've forked the project and published an own package: https://www.npmjs.com/package/mongodb_fixtures Feel free to use it 😄 |
It seems like many people (myself included) were receiving sporadic errors about mongodb background operations. This is because the drop command also clears indices for the collection, forcing mongodb to reindex the next time the collection is used. Switching the command from drop to removeMany keeps the indices intact and prevents this from happening.