NodeJS为Ember数据提供Sequelize JSON响应

时间:2015-12-04 18:51:13

标签: json node.js ember.js ember-data sequelize.js

我正在使用NodeJS和Sequelize为Ember-App(使用ember-data)创建API。我目前有api返回:

public class User{
    private ArrayList<User> users;
    public void addUser(User a){
         users.add(a);
         // Here I want to do the opposite. 
    }
}

由以下代码生成:

{"customer":{"id":2,
 "username":"jdsnell",
 "policies":
  [{"id":5,"policytype":"Life","createdAt":null,"updatedAt":null},  
  {"id":6,"policytype":"Auto","createdAt":null,"updatedAt":null}]
 }}

我需要响应才能返回Ember数据所期望的id,例如:

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});
    });
})

我将如何做到这一点?

0 个答案:

没有答案