Skip to content

Module - ChangeLog

It will track insert, update and delete operations on your entities.

Once you have it setup, assign you the role "ChangeLog.Admin" (You can get it via Roles_ChangeLog.ChangeLog_Admin), and in Admin UI, you will be able to see all changes in the entity named FF Change Logs.

Terminal window
npm add firstly@latest -D
src/server/api.ts
import { changeLog } from 'firstly/changeLog/server'
export const api = remultApi({
modules: [changeLog()],
})

Wrap your entity options with the withChangeLog function to opt-in changeLog.

import { withChangeLog } from 'firstly/changeLog'
@Entity('users',
withChangeLog({
// ...
}),
)
class User {}

Yes, that’s it! 🎉

Create your own @APP_Entity decorator and use it instead of @Entity.

APP_Entity.ts
import { Entity, type EntityOptions } from 'remult'
import { withChangeLog } from 'firstly/changeLog'
export function APP_Entity<entityType>(
key: string,
options?: EntityOptions<
entityType extends new (...args: any) => any ? InstanceType<entityType> : entityType
>,
) {
return Entity(
key,
withChangeLog({
...options,
// other app specific default options
}),
)
}