2013-10-08 98 views
0

我在试图弄清楚这个问题的时候很困难。mongodb - 收集更新实际上并没有更新

我试图发出基本上有一个数字,如更新所有匹配记录的集合级别更新:

# I actually am using PHP driver but using the console has the same result 
db.my_collection.update({si: '647522529'}, {$set: {cl:'2'}}); 

以上应该发现,是SI =“647522529”,然后更新所有记录CL = '2'。

的问题是上面的命令不会给任何错误或警告的,所以它看起来像它正确地执行,但是当我在“CL”运行不同的命令键它给不同的结果(2/1 ):

> db.runCommand({ distinct: 'my_collection', key: 'cl', query: { si: '647522529' } }) 
{ 
     "values" : [ 
       "2", 
       "1" 
     ], 
     "stats" : { 
       "n" : 113, 
       "nscanned" : 113, 
       "nscannedObjects" : 113, 
       "timems" : 1, 
       "cursor" : "BtreeCursor si_1" 
     }, 
     "ok" : 1 
} 

我做的事情不正确吗?我试过对数据库进行重新索引,但这也没有任何影响。

任何帮助将非常感谢!

回答