0

Our Web API returns Ember Data compatible objects with relationships defined like so:

{containers: [
    {
        id: "12345678",
        name: "name",
        items: [1, 2]
    }
 ],
 items: [
    {
        id: 1
        name: "item 1"
    },
    {
        id: 2
        name: "item 2"
    }
 ]
}

Notice that the item IDs are included in the container object, and that each related item is sideloaded in the same call. Is there any way to set up this kind of relationship with RestKit?

Matt Baker
  • 3,394
  • 3
  • 25
  • 35
  • possible duplicate of [Foreign key relationship mapping with RestKit](http://stackoverflow.com/questions/17326087/foreign-key-relationship-mapping-with-restkit) – Wain Mar 29 '14 at 19:43
  • That works with arrays of keys too – Wain Mar 29 '14 at 19:43
  • @Wain Thank you for that. I found that one but It wasn't clear that it would support arrays of keys as well. I'll try that one out! – Matt Baker Mar 29 '14 at 19:47
  • Yeah, rather than the transient being a string set it to transformable and you should be good. – Wain Mar 29 '14 at 19:59
  • @Wain I can't seem to make this work. One thing of significance is that I am NOT using Core Data object mappings, just normal ones. All of the examples I find that do this use Core Data classes. Is it possible to do this without Core Data? – Matt Baker Apr 06 '14 at 03:42
  • No. Core data only. The `addConnectionForRelationship` API is on the entity mapping and using core data is the only way RestKit knows how to look up the objects to be connected. Outside core data you need to configure some kind of 'relationship' yourself. – Wain Apr 06 '14 at 06:53
  • Core Data it is! Thanks @Wain – Matt Baker Apr 06 '14 at 15:02

0 Answers0