0
点赞
收藏
分享

微信扫一扫

nodejs操作mogodb修改数据信息


var mongodb = require('mongodb');
var server = new mongodb.Server('localhost', 27017, {auto_reconnect: true});
var db = new mongodb.Db('mydb', server, {safe: true});
db.open(function(err, db) {
if(!err) {
db.collection('mycoll', {
safe: true
}, function(err, collection) {
collection.update({id: 1}, {$set: {name: "lily"}}, {safe: true}, function(err, result) {
console.log(result);
});
} else {
console.log(err);
}
});
});


举报

相关推荐

0 条评论