Having a document of this form
{ "id" : 1,
"data": "some_data"
}
the method I'm using to find it is this one
myModel.findOne({ id: req.params.id})
this works fine, but now the model has changed and it looks like this
{ "item": {
"id": 1
},
"data": "some_data",
}
tying like this doesn't seem to work:
myModel.findOne({ item: { id: req.params.id } })
any ideas?
You can try the following:
myModel.findOne({ 'item.id': req.params.id})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.