简体   繁体   中英

Install mongoose with mongodb on different server

I have a dedicated setup where nodejs is on one server and mongodb on a different server. The mongoose installation works and my app correctly handles mongo, so I do not have an issue per se.

My question is: Considering that mongoose builds a native C++ driver during npm install using the mongodb code, will I have less performance because mongoose installs differently when mongodb is unavailable?

The docs state that both HAVE to be installed.

PS I would like to avoid "polluting" my node server with a database service it does not need.

Thanks to eryone.

You don't need to install mongodb on the server running your node app. The node-mongodb-native driver that's used by mongoose is a stand-alone javascript client library that allows your node app to connect to the mongodb server, issue commands, and retrieve responses. That server could be the same as your node server, or some other server on your network, or the internet.

Mongoose sits on top of the native node driver and provides the ability to define schemas and logic for your collections, but you can also access the native driver through mongoose to issue raw mongodb commands.

The mongoose NPM package includes the native driver, so you don't need to do anything beyond including the mongoose package with your app.

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