Search code examples
iosobjective-cparse-platformpfuser

parse query to see if friend info has changed


I am using parse as a server for my iOS application. One major component of the application is when a user updates their information, I want this new information to be available to their friends. Right now the only way i can think of to do this is by running a query with the current friend information and seeing if this matches the friend information. However, I do want to run a query for all friends as this would take a while. Is there any quicker way to accomplish this.

As an example starting information User: Name: Favorite color: Friends: Daniel345 Daniel Blue David

and then the user changes the information to be User: Name: Favorite Color: Friends: Daniel1345 Daniel Green David

how can i structure a query so that David's friend information will be update to show that Daniels new favorite color is green?


Solution

  • I recommend you do this query to know if a user have changed any value, not a specific one.

    You can do the following:

    1) When a user (user1) adds a friend(user2) to it's circles you add this friend's(user2) id into a table of all friends.

    1.1) In that table you can add a column called "updated". It will represent if the data of that user(user1) is updated in the user(user1) app.

    1.2) the table should look something like this (user(pointer),friend(pointer),updated(number))

    2) When one of the user(user1) friends changes (Updates) it's data you can change a boolean value(updated) in the friends list.

    2.1) You will need to do that to all the it's friends.

    3) To fetch the all the friends that have changed their data just get all the friends that the 'updated' value equals to 1

    Basically, every time a User fetches all it's friends that have changed their data you reset all the 'updated' values back to 0. If a user haven't fetched the data and a one friend changes it's data twice then nothing happens, the value remains 1 (Think of this value as a way of letting you know that you have an update in one/some of your friends)