Reputation: 2267
Is it possible to run a whereKey
on a PFQuery
with object keys within? Let's say I want to fetch all users with a current score higher than their previous? Something like this:
query.whereKey("score", greaterThan: ?previous?)
In this example, what should I enter instead of ?previous?
? Of course I could fetch all users and then make comparisons but that will be slow with many users.
Thanks
Upvotes: 0
Views: 119
Reputation: 9952
No, a Parse query can only compare a key against a provided object.
I would suggest making a beforeSave()
cloud code event that compares the new score with the previous upon saving and then sets another column (i.e. newHighscore
) to 1.
You can then query for all users with newHighscore
equalTo 1.
Next time you save the user score, if it's not higher than the previous score, you set newHighscore
to 0.
Upvotes: 1