question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@LinkingObjects get list without manual iterate by loop?

See original GitHub issue

Example from your official documentation about Inverse relationships :

https://realm.io/docs/java/latest/

public class Person extends RealmObject {
  private String id;
  private String name;
  private RealmList<Dog> dogs;
}

public class Dog extends RealmObject {
  private String id;
  private String name;
  private String color;
  @LinkingObjects("dogs")
  private final RealmResults<Person> owners;
}


RealmResults<Dog> brownFluffies = realm.where(Dog.class).equalTo("color", "Brown").equalTo("name", "Fluffy").findAll();
for (Dog brownFluffy : brownFluffies) {
    RealmResults<Person> owners = brownFluffy.getOwners();
}

OK. It’s work fine.

But I need to get Person’s name of all persons that has dog by brown color and name Fluffy. I wan’t to do manualy iterate by loop. Is Realm can get this kind of list? As result I need list of persons’s names. RealmResult<String> personNames

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cmelchiorcommented, Oct 15, 2017

Note that Realm objects are all lazy-loaded, so the difference between RealmResults<Person> and RealmResults<String> would be very minimal, but if you really need a list of strings then doing it manually is the only way for now.

Also, projections are not supported in Realm yet, but I did make a description of the concept in #5426 though.

0reactions
Zhuindencommented, Oct 14, 2017

Even in SQL this is called projection and Realm only provides the whole object as proxy

Read more comments on GitHub >

github_iconTop Results From Across the Web

Iterate through list and add to list without incurring ...
This would exit the method when a match is found, if there are no matches the person is simply added after the loop....
Read more >
continue - Manual - PHP
continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and...
Read more >
Fortran 77 Programmer's Guide - UBC Physics: Numerical Relativity
Most of the manual pages for these packages list the required libraries. ... loops are not executed if the upper limit is smaller...
Read more >
MIPSpro Fortran 77 Programmer's Guide - irix7.com
discussions of the CALL and RETURN statements in the MIPSpro Fortran 77 Language. Reference Manual). Fortran does not generate code to pass statement ......
Read more >
Arm® Compiler for Embedded FuSa User Guide
3 Getting Started with the SVE features in Arm Compiler for Embedded FuSa 6. ... When linking objects, specify ... Unroll all the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found