Start a new topic

KCSLinkedAppdataStore can only be stored but not fetched

I can save a relational entity with KCSLinkedAppdataStore. But I cannot fetch it using any methods, including queryWithQuery, loadObjectWithID. I know this module is still in beta test (http://devcenter.kinvey.com/ios/reference/api/Classes/KCSLinkedAppdataStore.html). If it works, would you please send me a sample code if convenient (yhandxiao@gmail.com) ? Thanks.

It actually fetches, but you have to downcast it to nsobject and get values  using  valueforkey . If you have your like.event ,  like.event.name will crash, however like.event.valueForKey("name") will work. So basically it works , but it's not very convenient.

No, it didn't, still can only store but not fetch relational data. 
If I fetch with KCSLinkedAppdataStore  a Like , the corresponding event is not resolved , however property "toUser" is being resolved.

Did KinveyKit 1.26 fix this issue for you?
Hi Yonghui, The 1.26 release is out http://devcenter.kinvey.com/ios/downloads
I will look into this.
The only method for programmers to work under it is to change the KCSUser* type to a NSDictionary, and then get the "_id", then by the _id query the KCSUserCollectionName , like : KCSQuery* query = [KCSQuery queryOnField:@"_id"

withExactMatchForValue:[(NSDictionary*)[[ fetched objectAtIndex:indexPath.row] from_user] objectForKey: @"_id"]

];



[userStore queryWithQuery:query withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil){}withProgressBlock:nil

];
KCSCollection* collection = [KCSCollection collectionFromString:@"name"

ofClass:[classname class]

];

_store = [KCSAppdataStore storeWithCollection:collection

options:@{KCSStoreKeyCachePolicy : @(KCSCachePolicyLocalFirst)}

];



if _store is defined by KCSAppdataStore, it can be used to fetch data. If _store is KCSLinkedAppdataStore, it cannot fetch anything. You can test it.

This is actually not a big deal. The real problem is that the loaded object is KinveyRef tyep, not the real referenced object. For example, if you have a invitee in your invitation table and the invitee is a link to the KCSUserCollectionName, then in your fetched data, invitee will be like {"_collection":"user","_id":"52b4e557dbec78f429ba821a","_type":"KinveyRef"} . This means programmers have to query in the KCSUserCollectionName again by the "_id" to get the user's name ! (or email, picture etc.) The ironic part is that in the fetched data the invitee IS a KCSUser* type, but when your use invitee.givenName, you get an error because it is a KinveyRef type.



I hope you understand what I mean. But if you test it, you will see it anyway.

Thanks.
What do you mean it does not work?
It appears that [KCSAppdataStore queryWithQuery:withCompletionBlock:withProgressBlock:] works fine. In the fetched answer, the linked attribute is KinveyRef, not the referenced object.



[KCSLinkedAppdataStore queryWithQuery:withCompletionBlock:withProgressBlock:] does not work.



I don't know how this will be designed. But I hope the referenced object can also be fetched in the answer. Thanks.
Login or Signup to post a comment