I need to know the model type of a hasMany array.
export default DS.Model.extend({
addresses: DS.hasMany('address', { async: true })
})
With a regular model you can do model.constructor.modelName
to find the type of the model. So if I am passed the addresses array, how do I find out that the type of the array elements are address
?
Update: Actually I solved my problem in a better way with the createRecord()
function on the array which automatically adds a record of the correct type to the array. It would still be interesting to know if the above is possible though.
Aucun commentaire:
Enregistrer un commentaire