[英]MongoDB query the field inside the array of the array
{ "_id": 1, "posts":[ { "_id": 1, "title": "my title", "content": "some post content here...", "comments": [ { "_id": 1, "text": "my comment" }, { "_id": 2, "text": "your_comment" } ] } ] }
Here how would I query/fetch the documents which match this text 'my comment' in the text field of comments array. 这里我将如何在comments数组的文本字段中查询/获取与此文本“我的注释”匹配的文档。
You can use this simple query for find
: 你可以使用这个简单的查询来
find
:
{
"posts.comments.text": "my comment"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.