'spring mongodb - How to provide match condition to check for empty array using spring data mongodb api?
how to perform below operation (it is the actual mongo query) using MatchOperation in Spring data mongodb ?
$match: { "docs": { $ne: [] } }
here docs is an array field and want to check that it is not empty.
Solution 1:[1]
I also had a similar problem, but I solved is as below.
MatchOperation mathOpertaion = match(Criteria.where("docs") .elemMatch(new Criteria().exists(true)));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ??? |