更新嵌套文件說我有一個數據結構是這樣的:MongoDB中
{
'name': 'test',
'anotherdoc': {
'something': 'someval',
'somenum': 1
}
}
現在,說我想設置的東西。起初,我雖然會這樣做:
collection.update({'_id': myid}, {$set: {'anotherdoc.something': 'somenewval'});
但是,這似乎是不正確的。它確實在那裏提供了一些數據,但它以一種奇怪的方式進行。在這種情況下,它會像這樣結束:
[
{
'name': 'test',
'anotherdoc': {
'something': 'someval',
'somenum': 1
}
},
['anotherdoc.something', 'someval']
]
當然,不是我在找的東西。
嗯,如實地我在python中進行這個測試,而不是在解釋器中。如果它與解釋器一起工作,則問題必須出現在我在python中的實現中。如果我仍然無法正常工作,我會去MongoDB論壇。 – defrex 2009-07-18 13:58:26