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 ] }
]);
字符串
返回min(dim_cm)>15的文档db.inventory.find( { dim_cm: { $all: {$gt:15} } } )
似乎是错误的
2条答案
按热度按时间w6lpcovy1#
相反,您应该使用
$not
和$lte
运算符来查找dim_cm
包含所有大于15的元素的文档。字符串
Demo @ Mongo Playground
引用:单一查询条件
nnt7mjpx2#
直观的语法是将
$min
和$gt
链接到$expr
中字符串
Mongo Playground