查询嵌入式文档数组
db.inventory.insertMany( [
{ item: "journal", instock: [ { warehouse: "A", qty: 5 }, { warehouse: "C", qty: 15 } ] },
{ item: "notebook", instock: [ { warehouse: "C", qty: 5 } ] },
{ item: "paper", instock: [ { warehouse: "A", qty: 60 }, { warehouse: "B", qty: 15 } ] },
{ item: "planner", instock: [ { warehouse: "A", qty: 40 }, { warehouse: "B", qty: 5 } ] },
{ item: "postcard", instock: [ { warehouse: "B", qty: 15 }, { warehouse: "C", qty: 35 } ] }
]);查询数组中的嵌套文档
db.inventory.find( { "instock": { warehouse: "A", qty: 5 } } )db.inventory.find( { "instock": { qty: 5, warehouse: "A" } } )指定查询条件在数组嵌套文档的字段上
指定查询条件在数组中嵌套文档的字段上
使用数组下标查询数组中嵌套文档中的字段
指定多个条件检索数组嵌套文档
单个嵌套文档中的字段满足多个查询条件
多个元素联合满足查询条件
其它查询导航
其它查询案例:
最后更新于