{
"_id": "590ad2c78eb79d16bde4a15d",
"user": "yejia@qq.com",
"password": "111111",
"__v": 0,
"lists": [
{
"_id": "590ad2d78eb79d16bde4a15e",
"update_at": "2017-05-04T07:05:52.174Z",
"create_at": "2017-05-04T07:05:52.174Z",
"title": "测试1",
"isChecked": [
false
],
"details": [
"未完"
]
},
{
"_id": "590ad3398eb79d16bde4a15f",
"update_at": "2017-05-04T07:07:28.784Z",
"create_at": "2017-05-04T07:07:28.784Z",
"title": "测试2",
"isChecked": [
false,
false
],
"details": [
"1232",
"333"
]
}
]
}
像这个例子,如果我要根据子文档的id:"_id": "590ad2d78eb79d16bde4a15e"查找子文档,该怎么操作?说明一下,直接用id查询我会,我不懂的是用子文档的id查询子文档。
可以查看mongoose的API文档,有关sub_doc操作的章节,http://mongoosejs.com/docs/subdocs.html
yourCollectionName.lists.id(your_id)