Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which mongo driver for node should I use?

The Node wiki lists a few different mongo driverrs for node. What are the pros and cons on each one?

Right now I want to efficiently tail a Mongo capped collection from node, but I suspect I will end up using mongo from node quite heavily and if stackoverflow can save me from having to switch to a different driver later that'd be great.

In general I have no particular interest in object relational mappers; I mainly want to make clean and efficient insert, update and find calls asynchronously.

like image 200
Dickon Reed Avatar asked Aug 10 '11 15:08

Dickon Reed


People also ask

Which drivers are useful to connect node js with MongoDB?

Connect your Node. js applications to MongoDB and work with your data using the Node. js driver. The driver features an asynchronous API that you can use to access method return values through Promises or specify callbacks to access them when communicating with MongoDB.

Should I use mongoose or MongoDB driver?

On the downside, learning mongoose can take some time, and has some limitations in handling schemas that are quite complex. However, if your collection schema is unpredictable, or you want a Mongo-shell like experience inside Node. js, then go ahead and use the mongodb driver. It is the simplest to pick up.

Is MongoDB good for node JS?

Node and MongoDB work very-well together, in part because Mongo uses a JavaScript engine built into the database since JavaScript is good at handling JSON objects. Compared to other databases, such as MySQL, MongoDB is fast for storing certain types of data and can be automatically scaled.

How do I connect to a node in MongoDB?

To connect a Node. js application to MongoDB, we have to use a library called Mongoose. mongoose. connect("mongodb://localhost:27017/collectionName", { useNewUrlParser: true, useUnifiedTopology: true });


1 Answers

It's hard to say which is the best.

My current favorites from the api-sugar point of view are:

  • Mongoose as a ODM
  • Mongoskin witch basically replaces the driver's callbacks-based api with one based on promises (when/then)
like image 123
clyfe Avatar answered Nov 04 '22 16:11

clyfe