简体   繁体   中英

Parse.com query in 2 clases can it be done?

i want to query my location class but need to only return results posted by the user that has a certain data criteria.

in my user fields i have a column called customer i only want to return the posted locations of the user that has the customer column as NO

so it would go as follows

look for users > only get users that customer column = NO > List Those Location Posts > let the user chose one by showing the users display name .... so it looks like i need to query 2 classes can i do this

i am using IOS 7 with Xcode 51 Beta3

My User class is as follows username, displayName, Customer, DatePosted, DateUpdated

My Location Class is as follows Location, PostedUser, DatePosted, DateUpdated

the PostedUser in the location class is linked to the User class

can this query be done?

i have tried but its not retuning anything for the label.text

// Create a query for places
PFQuery *query = [PFQuery queryWithClassName:@"Location"];
[query includeKey:@"postedUser"];
[query whereKey:@"displayName"
        equalTo:[PFObject objectWithoutDataWithClassName:@"Location"    objectId:_postedUser]];
NSLog(@"details from posted User  %@ .", _postedUser) ; 
// Query 1
PFQuery * userQuery = [PFUser query];
[userQuery whereKey:"Customer" isEqual:@NO];

// Query 2
PFQuery * locationQuery = [PFQuery queryWithClassName:@"Location"];

// Make sure this key in locationQuery matches the objects from userQuery
[locationQuery whereKey:@"postedUser" matchesQuery:userQuery]; 

[locationQuery findObjects];

This should return all location objects where "postedUser" is a reference to a user whose "Customer" key = @NO.

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