lundi 6 novembre 2017

Create Array of records of a model ember js

I have a model named 'notificationSettings' is as follows

import DS from 'ember-data';

export default DS.Model.extend({
  type: DS.attr('string'),
  email: DS.attr('string'),
  sendBeforeDays: DS.attr('number'),
  isInstant: DS.attr('boolean'),
  cutHours: DS.attr('number')
});

and by default I need an array of 4 records of this model with default values as follows

"notificationSettings": [{
      "type": "Booking",
      "email": "sunny.wayne@expedia.com,mahela.jayawardane@expedia.com",
      "isInstant": true,
      "cutHours": 72,
      "sendBeforeDays": -1
    },
    {
      "type": "Booking",
      "email": "",
      "isInstant": false,
      "cutHours": 72,
      "sendBeforeDays": -1
    },
    {
      "type": "Arrival",
      "email": "mahela.jayawardane@expedia.com",
      "isInstant": false,
      "cutHours": 72,
      "sendBeforeDays": 1
    },
    {
      "type": "Cancellation",
      "email": "sunny.wayne@expedia.com",
      "isInstant": false,
      "cutHours": 72,
      "sendBeforeDays": -1
    }
  ]

Whats the ideal way to do this? I looked at the createRecord, but only one record can be created at a time. My backend logic expecting the data to be in the above format and I will also have to update the 4 records that are created.




Aucun commentaire:

Enregistrer un commentaire