objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

ability to link queries with OR not just AND

Open chirastefan opened this issue 3 months ago • 1 comments

Use case

I have a DB where EntryA has one-to-many relationships with EntryB. I encountered a case where I have a text field, and I want to query the EntryA database to retrieve all entries filtered by that text field's value. So for value 'aa', I want to get all the EntryA values where EntryA.name contains 'aa' OR(not AND, which is the default) if EntityA.items contain items with name containing 'aa'

Code example


        final builder =
            store.box<EntryA>().query(EntryA_.name.contains('aa'))
              ..link(EntryA_.owner, Owner_.id.equals(123))
              ..backlink(EntryB_.parent, EntryB_.name.contains('bb'));

chirastefan avatar Nov 19 '25 21:11 chirastefan

Thanks for the suggestion! This is related to #497, but here the emphasis is on combining the conditions on the object with the linked object.

For anyone interested, please thumbs up the first comment!

greenrobot-team avatar Nov 24 '25 06:11 greenrobot-team