是否可以使用 mango 查询找到那些在数组字段中提供字符串的文档?
说,
const doc = {
_id: 'testdoc',
tags: ['pouch', 'couch', 'mysql'],
}
$db.find({ selector: {
tags: {
$has: 'pouch' // what goes here?
}
}})
Run Code Online (Sandbox Code Playgroud)
您必须使用 $elemMatch 运算符
{
selector: {
tags: {
"$elemMatch": "pouch"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如需更多文档,请前往此处
| 归档时间: |
|
| 查看次数: |
884 次 |
| 最近记录: |