我想更新我的文档,但是它没有完全成功。
// Initialize connection once
MongoClient.connect("mongodb://localhost:27017/testDB", function(err, database) { //"mongodb://localhost:27017/test"
if(err) throw err;
db = database;
});
我的收藏行看起来像这样:
{ "_id" : ObjectId("53f9379ce9575bbe9ec29581"), "name:paco", "status:student" }
现在,如果我想按照以下方式更新文档中的行:
db.collection('user', function(err, collection){
collection.update({'_id':ObjectID(req.session.loggedIn)}, {image : filename}, {w:1}, function(err, result){
console.log(result);
我只得到了:
{ "_id" : ObjectId("53f9379ce9575bbe9ec29581"), "image:filename" }
如何更新以获得这样的数据?:
{ "_id" : ObjectId("53f9379ce9575bbe9ec29581"), "name:paco", "status:student" , "image:filename"}
注意:本文中的英文冒号应该被替换为中文冒号。
import { ObjectID } from 'bson'
- Peter