Is it possible to use $and
and $or
logical operators when querying array?
Because when I create a collection with 2 documents
db.inventory.insertMany([
{ item: "planner", qty: 75, tags: ["blank", "red"], dim_cm: [ 25 ] },
{ item: "postcard", qty: 45, tags: ["blue"], dim_cm: [ 10, 50 ] }
]);
and query
db.inventory.find( { dim_cm: {$or: [ {$gt: 49}, {$size: 1} ] } } )
the result is error unknown operator $or
.
I can rewrite the query as
db.inventory.find( { $or: [{dim_cm: {$gt: 49}}, {dim_cm: {$size: 1}}] } )
but why isn't the first query variant valid?