2017-08-30 5 views
0

私は2つのSequelize中のモデルとそれらの間の多対多の関係を持っている:Sequelizeでネストされたオブジェクトを照会する方法はありますが、それをレスポンスに含めないでください。

StatusManifestation = db.define('status_manifestation', {/* attributes */}); 
Profile = db.define('profile', {/* attributes */}); 

StatusManifestation.belongsToMany(Profile, { through: 'status_manifestation_profile', foreignKey: 'status_manifestation_id' }); 
Profile.belongsToMany(StatusManifestation, { through: 'status_manifestation_profile', foreignKey: 'profile_id' }); 

私は特定のIDを持つプロファイルに関連するすべてのStatusManifestationを見つけたいです。私がやろうとしている何

はこれです:

StatusManifestation.findAll({ include: [{ model: Profile, where: { id: 'this_is_an_id' } }] }) 

しかし、応答がプロファイルを含むプロファイル属性を持つStatusManifestationモデルです。

プロファイル属性を返さずにこのクエリを実行するにはどうすればよいですか?

PS:この答えはでは動作しませんでした私https://stackoverflow.com/a/33826540/8255874

答えて

0

あなたが試すことができます:

StatusManifestation.findAll({ 
    include: [{ 
    model: Profile, 
    where: { id: 'this_is_an_id' }, 
    attributes: { 
     exclude: [attributes to exclude] 
    } 
    }] 
}) 
関連する問題