你如何在mongo中更新数组中的数组?

时间:2013-02-24 19:51:41

标签: mongodb document

user{
      '_id' : ObjectId(...),
      'Post' : [
                   {
                     'id' : ObjectId(...),
                      'Reply' : [
                                   '_id' : ObjectId(...),
                                   'Reply' : [
                                               ....*Repeated results*

                                             ]

                                ]
                    }                 

               ]

}

我试图让我的mongo数据库有一个递归结构。例如,回复回复。我如何访问我想要的结构,让我们说底部结构。 Post.Reply。$。回复似乎不起作用。 (回复还有其他字段,比如实际消息,时间,但是我把它们留给了示例)。

这是我试过的查询。

({
    'Post._id': ObjectId('512a48518f24a04b77946888'),
    '_id': ObjectId('5119cf32decedf8257ef6acf'), 
    'Post.Reply._id': ObjectId('512a49548f24a04b9b74ad6b')
}, {
    '$push': {
        'Wall.Reply.$.Reply': {
            'ParentId': ObjectId('512a49548f24a04b9b74ad6b'), 
            'UserId': ObjectId('511747a18f24a0069b7ed655'), 
            'Depth': 2, 
            'Time': datetime.datetime(2013, 2, 24, 14, 40, 52, 420056), 
            'Message': 'This post is not good!', 
            '_id': ObjectId('512a6cc48f24a04d189a1e3a')
        }
    }
})

0 个答案:

没有答案
相关问题