1 | export async function main( |
2 | transaction_type: "insert" | "update" | "delete", |
3 | schema_name: string, |
4 | table_name: string, |
5 | row: any, |
6 | old_row?: any |
7 | ) { |
8 | console.log(`[Main] Transaction: ${transaction_type.toUpperCase()} on ${schema_name}.${table_name}`); |
9 | console.log("[Main] New row data:", row); |
10 |
|
11 | if (old_row) { |
12 | console.log("[Main] Old row data (update/delete):", old_row); |
13 | } |
14 |
|
15 | |
16 | if (transaction_type === "insert" && table_name === "users" && row?.email) { |
17 | console.log(`[Main] New user created: ${row.email}`); |
18 | |
19 | } |
20 |
|
21 | |
22 | if (transaction_type === "update" && table_name === "users" && old_row?.email !== row?.email) { |
23 | console.log(`[Main] User updated email from ${old_row.email} to ${row.email}`); |
24 | |
25 | } |
26 | } |