I have a belongsToMany
I’m trying to query for in a smart view, but it’s complaining that no model exists.
// user model
User.belongsToMany(models.WorkPreferences, {
foreignKey: 'UserID',
otherKey: 'WorkPreferencesID',
through: models.UserxWorkPreferences
});
// work preferences
WorkPreferences.belongsToMany(models.User, {
foreignKey: 'WorkPreferencesID',
otherKey: 'UserID',
through: models.UserxWorkPreferences
});
// component.js - trying to query
@computed('collection')
get workPreferencesModel() {
return this.args.collection.rendering.collections.find(
item => item.name === 'WorkPreferences'
);
}
// in call
const userParams = {
filters: JSON.stringify({
aggregator: 'and',
conditions: [
{
field: 'UserID',
operator: 'equal',
value: stub['forest-User'].id
}
]
}),
'page[number]': 1,
'page[size]': 50
};
await this.store.query('forest-WorkPreferences', userParams)
// error
Uncaught (in promise) Error: No model was found for 'forest-work-preferences' and no schema handles the type
Yet I can see the relationship set on the User record:
Appreciate any insights. Thanks!