We're using RestKit to cache data from a remote web-service, similar to Stackoverflows API.
In the API has questions and tags, but instead of getting the tag in text we get the tag id.
The questions resource looks like this:
{
"items": [
{
"question_id": 11260172,
"tags": [
{ "tag_id" : 1},
{ "tag_id" : 2},
{ "tag_id" : 3}
],
"view_count": 1,
[...]
}
The tags resource looks like this:
{
"items": [
{
"id": 1,
"name": "c#",
},
{
"id": 2,
"name": "java",
},
{
"id": 3,
"name": "php",
}]
}
We would like to create a join table between questions and tags, so that the question can have many tags and the tag has many questions.
We have got one to many working but not the join table many to many. We therefore wonder how the RestKit many to many mapping should look for a relationship like this, and how the data model should look.
We have tried the following mapping, but it isn't many-to-many.
[tagMapping mapKeyPath:@"id" toRelationship:@"questions" withMapping:tagsQuestionsMappingMapping];
[questionMapping mapKeyPath:@"tags" toRelationship:@"tags" withMapping:tagsQuestionsMappingMapping];