jeudi 19 janvier 2017

EmberJS - How to establish hasMany relationship on same attribute

I have the below sample JSONAPI. I want to load it in ember data.

{
"data": {
    "id": "in",
    "type": "product-offering",
    "relationships": {
      "products": {
        "data": [
          {
            "type": "group-product",
            "id": "group-product-001"
          },
          {
            "type": "sub-product",
            "id": "sub-product-001"
          }
        ]
      }
    }

Can any one please let me know how can I have the relationship in product-offering model?

I want something like that..

export default DS.Model.extend({
  products: hasMany('group-product'),
  products: hasMany('sub-product')
});

How can I use the hasmany relationship on same attribute for 2 models.




Aucun commentaire:

Enregistrer un commentaire