This is a SQL (currently support only PostgreSQL) database trigger module for NestJS which allow you to use decorators on SQL triggers.
$ npm install nestjs-database-trigger --save
app.module.ts
import{TriggerModule}from"nestjs-database-trigger";TriggerModule.forRootAsync({imports: [UtilsModule],inject: [UtilsService],useFactory: async(utilsService: UtilsService)=>({connectionString: databaseUrl,tables: ["Notification"],}),});notification.service.ts
import{onTrigger}from"nestjs-database-trigger";
@Injectable()exportclassNotificationService{constructor(){}
@OnTrigger("Notification")asyncprintout(payload: MessagePayload){console.log(payload);}}Payload interface
interfaceMessagePayload<T=any>{table: string;action: "INSERT"|"UPDATE"|"DELETE";data: T|null;oldData: T|null;}We plan to support other SQL database in the future.
nestjs-database-trigger is MIT licensed.
Thanks goes to these wonderful people (emoji key):
kahoowkh 📖 | Marco Tse 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
