简体   繁体   English

MongoDB查询数组数组中的字段

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM