Search code examples
androidrealm

Android, realm. How to query all objects not attached to owners?


public class Person extends RealmObject {

    private Dog dog;
}

public class Dog extends RealmObject {

     @LinkingObjects("dog")
     private final RealmResults<PoolElement> owners = null;
}

Hi! Does anybody know if there's a way to query all Dogs not attached to any person?


Solution

  • Try

    realm.where(Dog.class).isEmpty("owners").findAll()