Details
-
Question
-
Resolution: Works as Designed
-
Minor - P4
-
None
-
3.4.3
-
None
Description
When running a query like that, we have an error "$in operator needs an array", even if the content of $oi expression is an array.
|
|
db.demo.aggregate(
|
[
|
{"$match":{"_id":{"$in":["aaa","bbb"]}}}, |
{"$project":{ |
"order_items":1, |
"orders":1, |
"oi":'$order_items.order_id' |
}},
|
{
|
"$addFields":{"sz":{"$size":"$oi"}} // This works, $oi is an array and $size works on arrays |
},
|
{"$match":{"orders.order_id": {"$in":"$oi"}} // This does not work even if $oi is an array |
]
|
)
|
I guess this is complicated for query engine to be sure that $oi is an array, and $in operator has been strengthen considering the fact that value must be an array, but is there a way to achieve that ?