日期:2014-05-16  浏览次数:20542 次

预先占位然后删除

预先占位在一个额外的字段,然后取消

comments = [ {name : "Name Surname", date : "1970.01.01", text : "this is a placeholder"},
             {name : "Name Surname", date : "1970.01.01", text : "this is a placeholder"} ]

db.posts.insert({
  comments: [],
  padding: 'lorep ipsum ... x N'
})


db.posts.update(query, 
                {$push: {comments: comment_data},
                 $unset: padding})

?