mongodb更新upsert创build新logging

我有这样的logging

{ "_id" : ObjectId("57025c35e31f7274c1195c26"), "token" : "0ffed58b-57ed-4a2a-bb09-97c64f0f2bd2", "key" : "silly key", "user" : ObjectId("55e3f8fcc78dc516096dc3e2"), "twlprofile" : "Test Blog" } 

这是collections中唯一的一个。 我想update ,需要更新upsert,如果它找不到任何东西,所以我有这个代码

 var id = "55e3f8fcc78dc516096dc3e2"; var tokendoc = { "token": "05c50aa0-5a8c-4fad-b27f-db64a0355b4f", "key": "silly key", "user": "55e3f8fcc78dc516096dc3e2", "twlprofile": "Test Blog" } var tokenrecord = tokensCollection.update( { where: { user: id } }, tokendoc, { upsert: true }, function(err,tokenres){ //this part not important right now }); 

如果我运行它,最终插入具有相同用户属性的另一个文档。 我也尝试使用BSON.ObjectID与IDvariables,它并没有帮助。

我如何才能像真正的upsert一样工作?