Wrong
Wrong

Reputation: 1263

Spring - Filter by not empty array not working in Mongo

I have the following query:

@CountQuery("{$and:[" +
                "{ 'active' : true }," +
                "{ 'budget' : { $ne: { $size: 0 } } }" +
            "]}")
Integer countByBudgets();

and this document:

{
  id: ...,
  active: true,
  budget: []
}

And the query above is returning 1 when it should return 0 as the budget field has no values.

What am I doing wrong?

Thanks

Upvotes: 0

Views: 622

Answers (1)

Wrong
Wrong

Reputation: 1263

Okay, changing the following part worked:

"{ 'budget' : { $ne: [] } }"

Upvotes: 1

Related Questions