セイルでモデルの関連付けを行っていますが、関連付けられたフィールドに基づいてクエリを作成できるかどうか知りたいです。
例:
User.js
attributes:{
classes: { collection: 'Class', via: 'students' }
}
Class.js
attributes: {
type: ...
students: { collection: 'User', via: 'classes'}
}
クラスのタイプに基づいて学生ベースの特定のクラスを取得する方法はありますか?現在、使用するとすべてが返されるため.populate()
です。(以下のロジックと似ているかもしれません)
User
.findOne({name: 'StudentA'})
.populate('classes')
.where({'classes.type':['type1', 'type2']})
.then(....)
ありがとう