Hello @JulienGaladrim,
Thanks for your message!
The first thing that came to my mind was to define a direct association BelongsTo('SalesRepresentative')
in your Orders definition, but I am not sure this is doable with Sequelize
Otherwise, you could create a smart field that would define the SalesRepresentativeId
on your Order, and create the scope on it (this example could be a source of inspiration).
Finally, if you want to keep the initial solution you picked, you can have a look to this example where filters, pagination and sorting are still taken into account.
Let me know!
Thanks.