I have two tables in my parse database. The first table is the users table, that contains users info like username, email, password,profile pic etc. The second table contains posts added by users. I want to fetch a post along with the details of the user who added that post. Can any one suggest me how to do that in swift language.
I have tried the following code :
let innerQuery = PFQuery(className: "Posts")
innerQuery.whereKey("pickUpLocation", equalTo: firstSectionLbls[0] as! String)
innerQuery.whereKey("destination", equalTo: firstSectionLbls[1] as! String)
innerQuery.limit = 10
innerQuery.skip = skip
innerQuery.orderByAscending("DepartureDate")
let query = PFUser.query()
query!.whereKey("username", matchesQuery: innerQuery)
query!.findObjectsInBackgroundWithBlock {
(results: [PFObject]?, error: NSError?) -> Void in
I have retried using pointer. These are the steps I used to create pointer. 1. created a column named user in users table and set its type to pointer. 2. Created another column with same name as "user" in another class named "Posts" as set its type to pointer.
Then I used the below code to fetch the user data along with post data.
let innerQuery = PFQuery(className: "Rides")
innerQuery.whereKey("pickUpLocation", equalTo: firstSectionLbls[0] as! String)
innerQuery.whereKey("destination", equalTo: firstSectionLbls[1] as! String)
innerQuery.limit = 10
innerQuery.skip = skip
innerQuery.includeKey("user")
innerQuery.orderByAscending("DepartureDate")
innerQuery.findObjectsInBackgroundWithBlock {
(results: [PFObject]?, error: NSError?) -> Void in
But now again I didnot receive the users data, though I received the posts data
includeKeyfor the user pointer column in your posts query.