Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objectify4 query a list attribute with a list condition

I have an object called Guy which has an attribute girlfriends type Key[]

Given a list of Longs which are the Girl's ids I want to query all the Guy's which have any of these girls as girlfriend.

For example (Guy: gilfriends):

 LuckyGuy: {a,b,c}
 Guy1: {b}
 Guy2: {c}

I want g such as:

 g({a,b}) = LuckyGuy, Guy1
 g({c})) = LuckyGuy, Guy2

I could make a loop:

for(i..n)
    resultSet.add(
        objectifyFactory.begin().load().type(User.class).filter("girlfriends", girlfriendId[i])
    );

But I'm sure there is a direct strategy.

Any idea?

like image 540
Jordi P.S. Avatar asked Apr 15 '26 07:04

Jordi P.S.


1 Answers

The datastore does not support 'or' queries. You will need to query for each of the 'girlfriend' IDs separately, and combine the result sets.

like image 89
Nick Johnson Avatar answered Apr 18 '26 13:04

Nick Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!