| 命中元素 | {tags: "mongo"} |
|---|---|
| 全含 | $all: ["mongo", "index"] |
| 长度 | $size: 3 |
| 同元素组合 | $elemMatch: {$gt: 80, $lt: 90} |
示例
示例
db.posts.find({ tags: "mongo" })
db.posts.find({ tags: { $all: ["mongo", "index"] } })
db.posts.find({ scores: { $elemMatch: { $gt: 80, $lt: 90 } } })$size 不能与其他条件共用同字段范围表达,精确长度判断只能单独写。