MongoDB + NodeJS - 通过变量递增

时间:2014-04-28 06:07:20

标签: javascript node.js mongodb

我正在使用nodejs的本机mongodb驱动程序,并试图通过我的nodejs程序中的变量增加某些文档中的值。

我有以下内容:

var foo = 2939.08
db.collection('mine').update({selected.col},{$inc:{bar:foo}},{upsert:true},function(err,doc){
    console.log(doc)
})

我每次都会在我的收藏中写入一个空值。

非常感谢任何帮助。

编辑** 我的代码也更接近这个

db.collection('mine').update({selected.col},{$set:{woo:top},$inc:{bar:foo}},{upsert:true},function(err,res){
    console.log(res);
})

0 个答案:

没有答案