0
votes

One of my fields for PFUser's is "ratingObject", a pointer to another class which has one column: "favouriteNumber". This keeps track of how many users follow this particular user. FavouriteNumber is just a number. I wanted to add this column directly to the PFUser row, however the app was crashing when I tried to increment this value from another user's account. Specifically when calling from user A:

userB.incrementKey("favouriteNumberInPFUser", byValue: 1)
userB.saveInBackground()

So I ended up creating this other class and adding a pointer to PFUser. However I need to perform a PFQuery taking into account this value. If it was in PFUser, no problem. But since it is in this other class, I can't really access it. I tried this:

var query2 = PFUser.query()
query2?.includeKey("ratingObject")
query2!.addDescendingOrder("ratingObject.favouriteNumber")

but it gives this error: [Error]: -ratingObject.favouriteNumber is not a valid order key (Code: 105, Version: 1.7.4)

1

1 Answers

1
votes

It should be a number on the user, and it can be if you update it from cloud code. This could either be an explicit function, or it could be a save hook if the current user is modified when they favourite another user.