lets say i have 2 tables, PetOwner and Pets. now i’m fetching all the pets of owner2 (a record from PetOwner table) so far so good but how can i sort my results by the name of pet ( records from Pets table ) ???
If you load Pet objects as a relation to PetOwner, you cannot sort “secondary” (that is related) objects.
The only way to sort them is if the request is sent directly to the Pet table.
@MarkPiller so there’s anyway i can load all the pets which are related to owner2 ? without creating a new relation ?? i already have a relation between PetOwner(pet) & Pets.
say i wanna load all the pets(records from table 2) which are related to owner2.
Yes, you can. Say the relation column in the PetOwner table is called “pets” and it points to the Pets table. With that structure, you can send the following “whereClause” to the Pets table:
PetOwner[pets].objectId = ‘owner2-objectId’
If you do not know onwer2’s objectId, but know something unique about him/her, say name, then the query changes to:
PetOwner[pets].name = ‘John Doe’