For Mongo, for an array I am able to use in peace:
db.fighters.find({"close_attacks": {$size: 3}},
{"_id": 0, "biography": 0})
.pretty()
and same for >
, ≥
, <
and ≤
, for example:
- 2>
- 2≥
- <5
- ≤5
Therefore the query would be as template for example:
db.fighters.find({$and: [{"close_attacks": {$type: "array"}},
{$expr: {$X: [{$size: "$close_attacks"}, 3]}}]})
Where $X
can be any of $lt
, $lte
, $gt
and $gte
About the pattern shown above see:
I want to know if is possible and how declare one query but working with a range about the size, such as:
- 2> and <5 (exclusive)
- 2≥ and ≤5 (inclusive)