I have a simple (made up for this question) model with an attribute called electricGuitars that has a few defaults predefined.
export default class guitarCollectionModel extends Model {
@attr('string') firstName;
@attr('string') lastName;
@attr({
defaultValue() {
return [
{
serialNumber: "sdfdsfadf",
colorCode: "dsfsadfdfa"
},
{
serialNumber: "234234234",
colorCode: "234234234323"
},
{
serialNumber: "oorprpprprpororprp",
colorCode: "rproproroprporp"
}
];
}
}) electricGuitars;
}
When I save the model (this.model.save()
) Ember Data POSTs to my API and almost everything is serialized correctly by default (no custom serializer or adpaters). API expects all property names to be dasherized.
{
"data": {
"attributes": {
"first-name": null,
"last-name": null,
"electric-guitars": [
{
"serialNumber": "sdfdsfadf",
"colorCode": "dsfsadfdfa"
},
{
"serialNumber": "234234234",
"colorCode": "234234234323"
},
{
"serialNumber": "oorprpprprpororprp",
"colorCode": "rproproroprporp"
}
]
},
"type": "guitar-collection"
}
}
The problem is that the serialNumber
and colorCode
properties inside of the electricGuitars
property/array have not been dasherized.
Is there an easy way to achieve this?
Aucun commentaire:
Enregistrer un commentaire