{
"_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)