Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a REST API With Express Modeling Data for the API Default Values in Mongoose

This course is outdated

This course needs to be updated because after using Animal.remove(), I got the following message after testing (node:10154) DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead. db connection closed

A lot of beginner users will not be able to know whats going on and how to fix it.

Mike Hardy
.a{fill-rule:evenodd;}techdegree seal-36
Mike Hardy
Full Stack JavaScript Techdegree Graduate 16,511 Points

I used the 'deleteMany' and it worked.

I'm also getting this warning: (node:16460) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

I agree!

1 Answer

Tobiasz Gala
Tobiasz Gala
Full Stack JavaScript Techdegree Student 23,529 Points

In most cases this is how your connect method should look like

mongoose.connect('mongodb://localhost:27017/collection_name', { 
    useNewUrlParser: true, 
    useCreateIndex: true,
    useFindAndModify: false