I am creating an API for an Ember-App (using ember-data) with NodeJS and Sequelize. I currently have the api returning:
`{"customer":{"id":2,
"username":"jdsnell",
"policies":
[{"id":5,"policytype":"Life","createdAt":null,"updatedAt":null},
{"id":6,"policytype":"Auto","createdAt":null,"updatedAt":null}]
}}`
Generated by the following code:
router.get('/:customer_id',function(req,res){ models.customers.find({ where:{ id:req.params.customer_id }, include: [models.policies] }).then(function(customers){
return res.json({customer:customers}); }); })
I need the response to return only the id's which is what Ember data is expecting, such as:
`{"customer":{"id":2,
"username":"jdsnell",
"policies":
[5,6]
}}`
How would I go about doing this?
Aucun commentaire:
Enregistrer un commentaire