Reputation: 1691
I have an Entity with different properties, one of the propery is Array of Objects , I'm working with Java using Objectify
now I want to make a query with filter to return count of all entities only with specific array size , E.g messages size=2
Example:
Kind: Request
and propery :
name messeges
{
"values": [
{
"K1": "V1",
"K2": "V2"
},
{
"K3": "V3",
"K4": "V4"
},
{
"K5": "V5",
"K6": "V6"
}
]
}
Something like :
int count = ofy().load().type(Request.class).filter("?? return count , to query with messages size is 2..").count()
Any suggestions plesae?
Upvotes: 1
Views: 462
Reputation: 39824
There is no way to make such query with the datastore.
But you could add a property to your entity, let's call it values_count
, to reflect the values
array size and make an equality query on that property instead (e.g. values_count=2
)
I'd make it a computed property, automatically updated whenever the entity is updated, see Is it possible to have a computed property on Google App Engine using Java?
Upvotes: 1