I am trying to sync phone contacts with parse user.
PFQuery *userQuery = [PFUser query];
[userQuery whereKey:#"username" containedIn:phones];
It was showing me results till I added a new phone number tried again and the query seems not to get correct result as it is not bring a new user in my phone contact.
Related
I'm using the parse backend to be database of my apps in Xcode (objective-c), but I don't know how to write a multiple condition parse format query. I want to convert the below query to a parse format query in the Xcode.
$msg_record = $this->db->query('SELECT msg, send_id, send_time FROM msg_record
WHERE (send_id=123456789 AND to_id=987654321) OR (send_id=987654321 AND to_id=123456789)
ORDER BY send_time ASC')->result();
Can anybody help me to convert the query? Thanks.
To create an or condition in a Parse query, you will have to make two (or more) subqueries which you merge with the orQueryWithSubqueries.
Be aware that you cannot translate SELECT directly from SQL to Parse.
This is what you are looking for:
PFQuery *query1 = [PFQuery queryWithClassName:#"msg_record"];
[query1 whereKey:#"send_id" equalTo:#"123456789"];
[query1 whereKey:#"to_id" equalTo:#"987654321"];
PFQuery *query2 = [PFQuery queryWithClassName:#"msg_record"];
[query2 whereKey:#"send_id" equalTo:#"987654321"];
[query2 whereKey:#"to_id" equalTo:#"123456789"];
PFQuery *mainQuery = [PFQuery orQueryWithSubqueries:#[query1,query2]];
[mainQuery orderByAscending:#"send_time"];
I have a requirement where i will be fetching data from a table using multiple 'OR' conditions in multiple columns, like either data in a column has to match or data in another column has to match for retrieving a row. And once this condition satisfied i need all the eligible objects to be ordered in their creation date(createdAt).
Here is what i am doing:
PFQuery *query1=[PFQuery queryWithClassName:#"Messages"];
[query1 whereKey:#"Receiver" equalTo:#"some-id"];
PFQuery *query2=[PFQuery queryWithClassName:#"Messages"];
[query2 whereKey:#"ThreadID" equalTo:#"some-threadID"];
PFQuery *finalQuery=[PFQuery orQueryWithSubqueries:#[query1,query2]];
[finalQuery orderByDescending:#"createdAt"];
NSArray *msgs=[query findObjects];
I am getting the messages but they are not lates, i.e. they are not sorted by 'createdAt'.
Can Anybody Help? Thanks
I have the following code, where I attempt to retrieve users based on an array of user IDs:
NSArray *userIDsWhoLikedPhoto = [self.photo objectForKey:#"usersThatLikedPicture"];
PFQuery *userQuery = [PFUser query];
[userQuery whereKey:#"objectId" containsAllObjectsInArray:userIDsWhoLikedPhoto];
[queryQuery findObjectsInBackground];
However, I always get the error "Error: $all only works on array fields (Code: 102, Version: 1.2.18)". I am not quite sure what I am doing wrong, since I am passing in an array as the query term.
Thanks!
Figured this out:
[userQuery whereKey:#"objectId" containedIn:userIDsWhoLikedPhoto];
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.
i'm using Parse.com I wanted to ask you something if you can ... How do I delete from the list the total number of users CurrentUser? I would avoid that the report will also be made with oneself: D Thank you all
Perfect Guys .. then I found the method ... In layman's terms to exclude the PFUser Current User from a query to show only the App users but not the CurrentUser is just the use of notEqualTo in the query but it should be associated with the string that we want to remove from the query
I hope this can help other people :)
Do not pay too much attention to the constants: D
PFQuery * query = [self.RelazioniUtenti query];
[query whereKey: FF_USER_NOMECOGNOME notEqualTo: [[PFUser currentUser] objectForKey: FF_USER_NOMECOGNOME]];
[query orderByAscending: FF_USER_NOMECOGNOME];
[query findObjectsInBackgroundWithBlock: ^ (NSArray * objects, NSError * error) {