I didn't expect MongoDB to have so many choices for Node. js drivers! I thought for a while! It turns out that in addition to the Driver found on the MongDB official website, there are also a lot of good people who have written several MongoDB drivers for Node. js !!
I originally wanted to use the mongoose Driver. Its advantage is that the package has many layers! No! Mongoose is a relatively high level. The famous advantage of mongoose is that it can be used in a similar way to SQL Schema to create a MongoDb database, and the writing method is relatively simple. However, I did not touch MongoDB for the first time, I am a bit familiar with MongoDB and can operate it on my own. Then, I really do not like to define such a column. Therefore, I finally decided to use the node-mongoDb-native Driver with the simplest function. However, after a while, I will know if it is the same as I thought!
The method for installing node-mongoDb-native Driver is very simple. You only need to use npm to install it. Therefore, you can use the following line to install it. If you have not installed npm, install sudo apt-get install npm first!
Npm install mongodb
If you use the above command to install the C ++ command, you must use the following command to execute it, the result is still useless, just use the following command.
Npm install mongodb -- mongodb: native
After the installation, you can start to use it. However, please note that the free version of MongoDB does not provide the Embedded Database function. Therefore, before connecting to MongoDB, start MongoDB first (SEE ).