mongodb
1.{userid:1, comments:[{id:1, content:"a"},{id:2, content:"b"}])
要查询出结果集为 {userid:1, comments:[{id:1, contents:"a"}]}
现在的mongodb不能做到这点,
要想达到同样的目的,可以将comments设为object类型,而不是数组
{userid:1, comments:{id1:{content:"a"}, id2:{content:"b"}}}
查询的语句是db.user.find({userid:1}, {'comments.id1':1})
结果是{userid:1, comments:{id1:{content:"a"}}}
Insert mode