MST

星途 面试题库

面试题:MongoDB Shell中如何高效查询嵌套数组内符合条件的文档

假设有一个集合,文档结构如下:{ _id: 1, items: [ { name: 'item1', count: 5 }, { name: 'item2', count: 3 } ] }. 请使用MongoDB Shell查询出items数组中count大于4的所有文档。
29.4万 热度难度
数据库MongoDB

知识考点

AI 面试

面试题答案

一键面试
db.collection.find({
    "items.count": { $gt: 4 }
});