查询嵌入/嵌套文档
db.inventory.insertMany( [
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }
]);嵌套文档查询
db.inventory.find( { size: { h: 14, w: 21, uom: "cm" } } )db.inventory.find( { size: { w: 21, h: 14, uom: "cm" } } )嵌套文档中的字段
嵌套文档中的字段等值查询
使用查询操作符查询
使用AND条件
其他查询导航
其他查询案例:
最后更新于