Reputation: 1431
Is it possible to find and update document where array size is less than field in this document? Right now I solve this problem by maintaining field with array size and query like:
bson.M{"name": serviceName, "active": true, "$expr": bson.M{"$lt": bson.A{"$count", "$limit"}}}
Where limit
is compared field and count
it is a field with arrays size.
Upvotes: 0
Views: 103
Reputation: 3390
{$expr: {$lt: [{$size: "$array"}, "$field_in_this_document_with_int_value"] }
In $expr
queries you can use any valid aggregator expressions.
Upvotes: 1