فهرست منبع

feat: Emit generic model updated/deleted event to backend

Owen Diffey 1 سال پیش
والد
کامیت
a7d593646b
1فایلهای تغییر یافته به همراه7 افزوده شده و 3 حذف شده
  1. 7 3
      backend/src/modules/DataModule.ts

+ 7 - 3
backend/src/modules/DataModule.ts

@@ -122,11 +122,15 @@ export class DataModule extends BaseModule {
 					if (!modelId && action !== "created")
 						throw new Error(`Model Id not found for "${event}"`);
 
-					let channel = `model.${modelName}.${action}`;
-
-					if (action !== "created") channel += `.${modelId}`;
+					const channel = `model.${modelName}.${action}`;
 
 					await EventsModule.publish(channel, { doc, oldDoc });
+
+					if (action !== "created")
+						await EventsModule.publish(`${channel}.${modelId}`, {
+							doc,
+							oldDoc
+						});
 				});
 			});
 	}