Npm package: mongoose or mongodb?
Which one you use? Which one is better choice and why?
I used to use mongoose maybe 2 years ago. I had mixed feeling, but I found everyone was using it back then so I comply. Now I want to connect somehow to MongoDB in new project and I wanted if are there any no no to go one way or the other. Or which one used to work better for others.
Mongoose is an ORM. Use it if you like the idea of using a pattern like User.findOne({ _id: ... })
. In general if you like working with models, automatic serialisation/deserialisation, etc.
The mongodb
package is a bare bones Mongo driver (which Mongoose uses under the hood). Use it if you prefer to run queries on the db itself without the convenience methods or plugins that are available to Mongoose.
@fiiv thanks. I should be more specific. I used to use mongoose maybe 2 years ago. I had mixed feeling, but I found everyone was using it back then so I comply. Now I want to connect somehow to MongoDB in new project and I wanted if are there any no no to go one way or the other. Or which one used to work better for others.
If you are comfortable then i would just use the native driver and create your own lightweight models.
Please sign in to leave a comment.