Expected behavior
I have a MongoDB collection named Clients which has an optional boolean field deleted
. In the default view of the collection in Forest Admin, I want to filter out the clients which have this boolean setup as deleted: true
. The idea is to have another segment which will display only the clients with this field being true
(I have already achieved this).
I looked at collection overrides, but there is no read
functionality to override.
I also looked into the collection hooks for listing the items, both before and after. I wasn’t able to find documentation around altering the default results.
The desired code will look something like this:
collection.addHook('After', 'List', async (context) => {
context.records = context.records.filter(record => record.deleted);
});
OR
collection.addHook('After', 'List', async (context) => {
return context.records.filter(record => record.deleted);
});
Would appreciate some clarification if this is actually possible. Thank you!
Context
- Agent technology: NodeJS
- Agent (forest package) name & version: @forestadmin/agent 1.35.16, @forestadmin/datasource-mongoose 1.7.3
- Database type: Mongo DB