简体   繁体   中英

Parse get object from relation

I'm trying to get groups which is member of current User.

I tried a lot of things but parse is returning null.

let innerQuery = PFUser.query()
let currentUser = PFUser.currentUser()
innerQuery?.whereKey("objectId", containedIn: [currentUser!.objectId!])
let query = PFQuery(className: "Group")
query.orderByDescending("updatedAt")
query.whereKey("members", matchesQuery: innerQuery!) 

query.findObjectsInBackgroundWithBlock { (groups, error) in
            print(error)
            print(groups)
        }

Try getting rid of the innerquery altogether and just use query.whereKey("members", equalTo: PFUser.currentUser()!.objectId!)

Assuming you want to query for the objectId of the current user in your members class. Delete both lines with innerquery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM