[MongoDB] Query trong MongoDD
-
Chào mọi người mình có một document như thê này trong db
{
"_id": {
"$oid": "5b59706b774ca401880ebad7"
},
"createdAt": "July 26, 2018",
"title": "What is Lorem Ipsum?a",
"description": "Lorem Ipsum.",
"body": "Lorem Ipsum is simply dummy text of the printing and typesetting industry",
"author": "lorem",
"comments": [
{
"createdAt": "July 27, 2018",
"_id": {
"$oid": "5b5ac6b9a587f01b80ca9df2"
},
"author": "author1",
"message": "hello"
},
{
"createdAt": "July 27, 2018",
"_id": {
"$oid": "5b5ac6c3a587f01b80ca9df3"
},
"author": "author2",
"message": "hello again"
},
{
"createdAt": "July 27, 2018",
"_id": {
"$oid": "5b5addcbb301c504342f82c7"
},
"author": "author3",
"message": "dsdsd"
}
],
"__v": 0,
"updatedAt": "July 27, 2018"
}
Mình muốn lấy nội dung của từng comment trong mảng theo id của comment thì làm như thế nào vậy? Cảm ơn mọi người.
-