Filtering records in related data view

Hi Forest Admin team,

Is it possible to exclude entries from related data views?

Use-case: I have a user & a team models and User.belongsTo(team) and `. When users are deleted, only a deletion timestamp is set & the record is not deleted from SQL database.

Is it possible to filter associated records, so that only undeleted users appear in team’s related data (and vice versa)? I could not find anything helpful pointers in sequelize’s docs about this.

Hi @Karlis_Lauva and welcome in our community :wave: !

If you want to never show deleted user you might want to check that.
So what you should do in your model is:

const User = sequelize.define('user', {
  // Your attributes here
}, {
  paranoid: true,
  deletedAt: 'myTimeStampOfDeletion'

And it should remove all deleted users for all teams !

If you want to remove it only for a specific team, then I strongly suggest you to use our scope feature. And on that scope you add a filter to make sure your deletedAt is null :wink:

Hope this will help you :pray: !