Using PFQuery's containsAllObjectsInArray results in error - ios

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];

Related

PFQuery Mixing nearGeoPoint with Bool

When I run the following
PFQuery *query = [PFQuery queryWithClassName:#"EventsTable"];
[query setCachePolicy:kPFCachePolicyNetworkOnly];
// Only active items
[query whereKey:#"active" equalTo:[NSNumber numberWithBool:YES]];
// Query by distance from current location
[query whereKey:#"geoLocation" nearGeoPoint:currentLocation];
// Only download objects that match the appropriate key
[query whereKey:#"keyedItems" containedIn:keysArray];
[query findObjectsInBackgroundWithBlock:^(NSArray *eventArray, NSError *error) {
It goes into an infinite loop with no error messages. But If I drop the nearGeoPoint it works fine, or if I keep the nearGeoPoint but drop the active it also works. But dropping the containedIn and keeping the nearGeoPoint and the active also fail the same way. I have also tried rearranging the order but no luck.
Any suggestions?
At first I wasn't able to find an error message so I assumed that it was stuck in the block, but alas here it is
Error: Error Domain=Parse Code=1 "{"code":1,"message":"Internal server error."}" UserInfo={error={"code":1,"message":"Internal server error."}, NSLocalizedDescription={"code":1,"message":"Internal server error."}, code=1} {
NSLocalizedDescription = "{\"code\":1,\"message\":\"Internal server error.\"}";
code = 1;
error = "{\"code\":1,\"message\":\"Internal server error.\"}";
}
This sounds like a parse server error to me - Is that correct?
The issue is that the table was so large it was unable to handle the query. The fix was just as mentioned above - to create an index. In this case I was able to turn on automatic indexing in the MongoDB. That solved the problem.

Parse Query wherekey: containedIn: does not work

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.

How can I load objects in PFQueryTableViewController with parse version 1.12.0 in Objective C?

Somebody know how can I get the objects from PFQueryTableViewController with the new SDK Parse Objective C version 1.12.0?
I got this error on debug shell when objectsDidLoad and objectsWillLoad methods are executing:
[Error]: improper usage of $dontSelect (Code: 102, Version: 1.12.0)
I'm running parse-server on my own dedicated server
Edit
Here is my code:
- (PFQuery *)queryForTable {
PFQuery *bann = [PFQuery queryWithClassName:#"Banned"];
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query orderByDescending:#"createdAt"];
[query whereKey:#"qUser" doesNotMatchKey:#"bannedUser" inQuery:bann];
if (self.objects.count == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
return query;
We can't really help you when you don't post any code.
A quick search for Parse's error code 102 brings up the follow:
/**
* Error code indicating you tried to query with a datatype that doesn't
* support it, like exact matching an array or object.
* #constant
*/
INVALID_QUERY: 102,

getObjectInBackgroundWithId: using pointer [ Parse ]

First i get the current user and the connected book to that user (It's a pointer to a book objectId). Then i want to find the book using the getobjectinBackgroundWithId method and then display the book name. When i change getObjectInBackgroundWithId:storeUserID to getObjectInBackgroundWithId:#"f4Dg92xC2" it works perfect!
PFUser *currentuser = [PFUser currentUser];
storeUserID = currentuser[#"connectedBook"]; //Store book id in a string
NSLog(#"%#", storeUserID); // what i get <Book:f4Dg92xC2:(null)>
PFQuery *query = [PFQuery queryWithClassName:#"Book"];
[query getObjectInBackgroundWithId:storeUserID block:^(PFObject *books, NSError *error){
PFObject *bookObject = books[#"bookName"];
NSLog(#"bookName:%#", bookObject);
}];
when i run this, the NSLog with the book name, shows:
Error: bad special key: objectId (Code: 102, Version: 1.2.20)
2014-09-17 23:28:56.529 MyApp[18977:90b] bookName:(null)
Thanks a lot in advance!!
Your comment //Store book id in a string is incorrect. A pointer doesn't return the string object id, it returns the object itself. So you already have it and you don't need to call getObjectInBackgroundWithId:.
The log <Book:f4Dg92xC2:(null)> even tells you it's a Book instance (not an NSString instance).

How to Remove PFUser Current User from List Total User?

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) {

Resources