inventid / tails

Models on the fly!
MIT License
1 stars 0 forks source link

Allow initialization of relations via JSON array #44

Open joostverdoorn opened 9 years ago

joostverdoorn commented 9 years ago

We already allow singular relations to be initialized when they're passed from the backend in json, for example:

"fruit": {
  "id": 8,
  "brand": "Fuji",
  "basket": {
    "id": 4,
    "name": "Apple basket"
  }
}

This will create a basket and link the fruit and basket together. It would be nice to have it for plural relations as well:

"basket": {
  "id": 4,
  "name": "Apple basket",
  "fruits": [
    {
      "id": 8,
      "brand": "Fuji"
    },
    { 
      "id": 6,
      "brand": "Granny Smith"
    }
  ]
}

This should create two fruits and put them in the basket.

This shouldn't be too hard to build.