var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/userCollectionDB";
MongoClient.connect(url, function(err, db){
var collection = db.collection('users');
var user = {firstName : "Ivan", lastName : "Ivanov", age: 30};
collection.insertOne(user, function(err, result){
if(err){
console.log('sssss');
return;
}
console.log(result.ops);
db.close();
});
});
-
Вопрос задан
-
1106 просмотров