1

in the official docs, https://realm.io/docs/java/latest/#link-queries - there's an example how to select owners of "Brown Fluffy" dogs.

My questions is, how do I select only those not having Brown Fluffy (and, obviously, those having no dogs at all)

I do not see how can one achieve this result by, say, using .not().beginGroup().equalTo(...).equalTo(...).endGroup() (that someone with previous SQL experience would try)

Thanks a lot in advance!

saabeilin
  • 610
  • 7
  • 15

1 Answers1

1

Have you tried

.not().equalTo(...).findAll().where().not().equalTo(...).findAll();

?

Chaining link queries is a bit tricky, but if I understand correctly, that is what you should try.

EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428
  • Thanks @EpicPandaForce, I need to check it. I really feel that something like "Realm queries for those thinking in tables/SQL" is something needed. Do I understand it right that `.equalTo()` for a linked entity is more or less close to `HAVING` or `EXISTS` clause in SQL? ;) – saabeilin Nov 22 '17 at 23:32
  • EqualTo is more like `==` – EpicPandaForce Nov 22 '17 at 23:41
  • Yes sure, for the object's own fields, but behaves a bit different when filtering on linked objects, right? – saabeilin Nov 23 '17 at 10:45
  • Ah yeah, in that case it's kinda like `if there is at least one linked object that ___ then` – EpicPandaForce Nov 23 '17 at 10:49