Parse.com: How to compare index keys with objects?

I am using the parse.com backend service for an iOS application, and I have a problem with processing it properly. I need help with the whereKey: matchesKey: inQuery method;

I have this code:

//NOT WORKING
PFQuery *query1 = [PFQuery queryWithClassName:@"Object"];

PFQuery *query2 = [PFQuery queryWithClassName:@"ObjectsRelations"];
[query2 whereKey:@"user" equalTo:[PFUser currentUser]];

[query1 whereKey:@"objectId" matchesKey:@"objectPointer" inQuery:query2];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    // No objects
}];

It does not work the way I want. I tried several ways to compare the "objectPointer" key in the "ObjectsRelations" class (which is a pointer to an instance of the Object class) against the actual object in request 1. I do not return any objects because the comparison does not work the way I want, since the key is objectId is just a string, and the objectPointer key is a pointer to an object.

, , , api-, objectId !

//WORKING
PFQuery *query = [PFQuery queryWithClassName:@"Object"];

PFQuery *query2 = [PFQuery queryWithClassName:@"ObjectRelations"];
[query2 whereKey:@"user" equalTo:[PFUser currentUser]];

[query2 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    PFObject *firstObject = [((PFObject*)[objects firstObject]) objectForKey:@"objectPointer"];

[query whereKey:@"objectId" equalTo:firstObject.objectId];

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    //Getting the objects correctly from the class Object!
}];
}];

api-? ?

- - , : ()

[query1 where:SELF matches:@"objectPointer" inQuery:query2];

?

+4
3

, Parse :

object_id

, ( ) ObjectRelations. / , objectId . /, .

, , , , Parse .

+2

String, , , , . , . , Cloud Code.

, :

//Inner query
//Library containing pointer<Deck> & pointer<User>
PFQuery * subscriptions = [PFQuery queryWithClassName:@"subscription"];
[subscriptions whereKey:@"User" equalTo:[PFUser currentUser]];
//Outer query
//Pull down a list of deckStore objects not included in the subscriptions for current user
PFQuery * decks = [PFQuery queryWithClassName:@"deckStore"];

:

[decks whereKey:@"objectId" doesNotMatchKey:@"deckString" inQuery:subscriptions];

:

[decks whereKey:@"this" doesNotMatchKey:@"deck" inQuery:subscriptions];

, :

Parse.Cloud.afterSave("Deck", function(request) {
    var deck = request.object;

    // To make sure this is the first time of "afterSave" of this object.
    if (deck.createdAt.getTime() == deck.updatedAt.getTime()) {
        // "this" is the column which contains the pointer of the object itself.
        if (deck.get("this") == null) {
            deck.set("this", deck);
            deck.save();
        }
    }
}
+1

. :

PFQuery *query1 = [PFQuery queryWithClassName:@"tableClass"];
[query1 whereKey:@"objectId" equalTo:[(PFObject *)[object objectForKey:@"pointerField"] objectId]];

PFObject *obj1 = [query1 getObjectWithId:[(PFObject *)[object objectForKey:@"pointerField"] objectId]];
NSString *pointerName = [obj1 objectForKey:@"name"];
0

All Articles