您的当前位置:首页正文

nodejs操作mongodb

2024-09-05 来源:小奈知识网


/**

学习笔记:nodejs操作mongodb

2021/4/6

*/

#nodejs操作mongodb

`

var mongodb = require('mongodb');

var server = new ('localhost', 27017, {auto_reconnect:true});

var db = new ('mydb', server, {safe:true});

oArray(function(err,docs){

('find');

(docs);

});

(function(err,doc){

('findOne');

(doc);

});

}

});

.');

oArray(function(err,docs){

(function(e){

;

});

});

*/

/*

//新增数据

var tmp1 = {username:'linjunjie',password:'810327'};

(tmp1,{safe:true},function(err, result){

(result);

});

*/

/*

// 删除数({username:'limingxia'},{safe:true},function(err,result){

(result);

});

*/

/*

//更新数据

({username:'linjunjie'}, function(err, result){

(result);

});

*/

/*

}

})

}else{

{$set:{username:'limingxia'}}, {safe:true},

(\"connect failed\");

}

});

*/`

因篇幅问题不能全部显示,请点此查看更多更全内容