How do I limit the amount of objects Realm returns? .findAll returns all rows matching the query and .findFirst returns only the first. But what about something like first 1
One way could be this, if you really want only RealmResults, using Stream limit method:
//get all results of your choice query
RealmResults entities = realm.where(TypeClass.class).findAll();
//limit using Stream
List ids = Stream.of(entities).limit(10).map(x -> x.Id).collect(Collectors.toList());
//return only those ids elments
return realm.where(TypeClass.class).in("Id", ids.toArray(new Integer[])).findAll();