0

I am using Parse cloud as a backend in my app. Following are the tables in Parse,

- Users

objectId      name
    1         John
    2         Mick
    3         Nirav


- UserConnection

objectId  senderObjectId  receiverObjectId  connectionType
    1         3                  1            connected
    2         2                  1            deleted
    3         2                  3            accepted

(e.g : Here in UserConnection table at objectId 2, the connection between Mick and John is deleted)

Now my query is that, How to fetch user list along with the connectionType for the particular user ?
For example if the user Mick fetches the user list from Users table, result should be,

name    connectionType
John      deleted
Nirav     accepted

How to retrieve data from both Users and UserConnection in a single query using Parse?

1 Answer 1

0

For what programming language you are asking? I can give you an example in Swift.

var innerQuery = PFQuery(className: "User")
innerQuery.whereKey("senderObjectId", equalTo:PFUser.currentUser())

var query = PFQuery(className: "UserConnection")

query.includeKey("senderObjectId")
query.whereKey("user", matchesQuery:innerQuery);

query.findObjectsInBackgroundWithBlock...

Let me know if that works for you :) I have also quite many issues about queries and parse...

Sign up to request clarification or add additional context in comments.

2 Comments

In the whereKey do you mean objectId in place of user ?
in fact, it should be the senderObjectId as this is the pointer to your user you are asking for, right? I updated my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.