1. Preparation
1. Create the table to be read in mongodb
Create database mongotest
Refer to the documentation of node-mongodb-native: https://github.com/mongodb/node-mongodb-native
var server = new mongodb.Server("127.0.0.1",27017,{});//Local 27017 port
new mongodb.Db('mongotest',server,{}).open(function(error,client){//Database: mongotest
If(error) throw error;
var collection = new mongodb.Collection(client,'user');//Table: user
Collection.find(function(error,cursor){
cursor.each(function(error,doc){
if(doc){
console.log("name:" doc.name "age:" doc.age);
}
});
});
});
Demo reference document for adding, deleting, modifying and checking