Getting the record being updated

Hello, I am using the forest admin with nodejs and nestjs with a postgres db.

I would like to get the current record being updating using the before (or after) update hook.
I could see that I can get all the records in the collection using the context.collection where the collection is the argument of the callback function, but I’m only interested (and required) to get the actual record being updated.
I’ve tried all the methods of the context and none of them seemed to work, any idea on what I should do?

Hello @genzo
Welcome to the forest admin community

You may use:

const records = await context.collection.list(
  context.filter,
  ['the', 'fields', 'you', 'need']
);

Note: you may check the following API reference for information, but if you are using a modern IDE, autocompletion should work everywhere

2 Likes

Exactly what I wanted, thanks!