I need to do a simple query sort with Parse.
I have two classes: Captain
and Boat
. Every Captain
has a Boat
point
There is a scalable solution for this, with rather minimal overhead: Currently you have a table of boats and a table of captains, where each captain contains a pointer to a boat.
You should add a third table - let'c call it 'captains boats', which contains all the boats that are contained in a captain object. You maintain it by adding the boat when a new captain is added and by removing it from the table when a captain is deleted.
In order to sort the captains by their boats:
Query 'Captains', use the 'containedIn' method with the boat list from step 1: [captainQuery whereKey:"boat" containedIn:boatList]
.
Now you have only the captain objects you need (out of a possible million). Sort them locally according to whatever.