2016-11-29 7 views
2

私のような2 entitesとの関係は、私は1つのクエリ内のすべての箱とそのユーザーを検索したいSequelize JS「を含む」と「生」

entities.Chest.belongsTo(entities.User) 

(すべての胸には一人のユーザーを持っている)持っているので、私はやります

entities.Chest.findAll({include:[{model: entities.User}]}) 

しかし、私は、プレーンなオブジェクトとしてそれらを操作することを好む、私は

entities.Chest.findAll({raw:true, include:[{model: entities.User}]}) 

を行い、その結果は、全くHOをユーザーが含まれていません。私はこれを達成することができますか?参加すると

ご覧のよう

答えて

3

は、生のは、いくつかの問題を抱えている だけインスタンスメソッドを使用してみてください(issueがある)#toJSON

entities.Chest.findAll({include:[{model: entities.User}]}) 
    .then(function(chestsSeq){ 
    var chests = chestsSeq.toJSON(); //same as chestsSeq.get({}); 
    //do something with raw chests object 
    }); 
関連する問題