查询数组
db.inventory.insertMany([
{ item: "journal", qty: 25, tags: ["blank", "red"], dim_cm: [ 14, 21 ] },
{ item: "notebook", qty: 50, tags: ["red", "blank"], dim_cm: [ 14, 21 ] },
{ item: "paper", qty: 100, tags: ["red", "blank", "plain"], dim_cm: [ 14, 21 ] },
{ item: "planner", qty: 75, tags: ["blank", "red"], dim_cm: [ 22.85, 30 ] },
{ item: "postcard", qty: 45, tags: ["blue"], dim_cm: [ 10, 15.25 ] }
]);数组查询
db.inventory.find( { tags: ["red", "blank"] } )db.inventory.find( { tags: { $all: ["red", "blank"] } } )查询数组中的元素
多条件查询数组中的元素
使用多条件查询数组中的元素
数组中的元素同时满足多个查询条件
使用数组下标查询数组中的元素
使用数组长度来检索
其它查询导航
其它查询案例:
最后更新于