简体   繁体   中英

What is the best way to use mongoDB with node.js?

I need to run MongoDB with node.js both locally, and on cloud services such as Nodester and MongoHQ. I would like to have minimal dependencies, for instance I don't really want to use Express or Mongoose right now. Basically, I'd like to run it as "directly" as possible

I have installed Mongo locally using Macports, and then using Mongojs module to talk to it from my node.js app. That works okay, running locally. But I see that Mongojs is supposedly wrapping the mongo-native module. Does that make it redundant with the Macports installation of Mongo, or is mongo-native just a client? And will Mongojs work to talk to a database hosted on MongoHQ, from an app hosted on Nodester? Finally, is Mongojs a good choice, or is there a better one?

I guess there are just so many interconnected things that I am getting confused and would like an explanation of how they all fit together and what standard practices are. For what it's worth , this is for a personal project, but I'd like to make it public, so I need for it to work with cheap or free hosting services.

It depends on your needs. I'm the author of the mongodb native driver and I would say that if you don't have very specific performance needs mongoose might make sense since it lets you do a bit of modeling for your documents and is closer to the concept of an ODM. For the wrapper you are using there are a whole bunch of them. Have a look at

http://mongodb.github.io/node-mongodb-native/

and

https://github.com/christkv/node-mongodb-native

I've tried to add all projects that might be relevant and each time I build the docs it pulls in stats to mark the projects as active or not.

If you need raw performance use my driver directly or one of the thin wrappers around it like mongojs or mongoskin.

I'm talking with Aaron one of the mongoose writers about maybe trying to create a framework half way between mongoose and the driver, but it's just a talk at the moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM