how can i sort an query result by the number of related objects ??
say i have a table “OWNER1” and inside of it i have two entities “owner” & “pet” (pet entity have a relation to PETS1 table , one to many relation)
so how can sort it so that owner with most pets will be at top at my retrieved results???
Hi,
There is no such built-in option in Backendless SDK, you will have to load all the objects and sort them manually in your code. Other option is to add a column which will keep the number of relations, this way you will be able to sort the results by this column.
i can go with the second option which says : add a column which will keep the number of relations. but one question, do i have to manually count and store the total count of relation in column or i can use any built in login for it ??
You can use Business Logic for kind of automated counting, but you’ll have to manually count the number of relations and save this value to a column in the handler’s code.