-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Items duplicating when restarting server #51
Comments
This part in your code:
will create 2 new items (an AK and an AWP) every time the server starts up. If you want to clear these out, drop the Items collection and run your code once. Then you can remove those lines and restart the app as many times as you want. |
What I should do is add a |
So, either by using
|
Yep. Though the |
A good solution would be to do this:
By doing this you remove every item in the DB and then insert an array of the predefined items into it. Hope it helps! @andrewda Maybe this could go into Chapter 4.4 instead of what's already there? Or it might be confusing for people that are new to mongoose/MongoDB? |
So for some reason, every time I re-run app.js, the list just duplicates its self and adds more to the document as shown here:
I am unsure if this is how it was intended, however clearly duplicates are not something we want around.
My code so far:
ignore the useMongClient and mongoose.promise, those were for getting rid of the errors.
The text was updated successfully, but these errors were encountered: