From 7c2a7fd340b8a88a0d36ae1e4f3e13bc230f087f Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 8 Jul 2017 15:42:44 +0200 Subject: [PATCH] add trigger in all database action create, update, delete --- controller/hk_controller.anubis | 9 ++++++++- controller/hk_trigger.anubis | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/controller/hk_controller.anubis b/controller/hk_controller.anubis index fa68d27..cd1181f 100644 --- a/controller/hk_controller.anubis +++ b/controller/hk_controller.anubis @@ -79,8 +79,15 @@ public define One since trigger_to_add is hk_trigger(name, t_type, call_back), if t_type is { + before_create then println(">>> ADD TRIGGER 'before_create' to table "+_table_name);add_trigger(ctrl.triggers.before_create, trigger_to_add), + after_create then println(">>> ADD TRIGGER 'after_create' to table "+_table_name); add_trigger(ctrl.triggers.after_create, trigger_to_add), + before_update then println(">>> ADD TRIGGER 'before_update' to table "+_table_name);add_trigger(ctrl.triggers.before_update, trigger_to_add), - after_update then println(">>> ADD TRIGGER 'after_update' to table "+_table_name);add_trigger(ctrl.triggers.after_update, trigger_to_add) + after_update then println(">>> ADD TRIGGER 'after_update' to table "+_table_name); add_trigger(ctrl.triggers.after_update, trigger_to_add), + + before_delete then println(">>> ADD TRIGGER 'before_delete' to table "+_table_name);add_trigger(ctrl.triggers.before_delete, trigger_to_add), + after_delete then println(">>> ADD TRIGGER 'after_delete' to table "+_table_name); add_trigger(ctrl.triggers.after_delete, trigger_to_add) + } } . diff --git a/controller/hk_trigger.anubis b/controller/hk_trigger.anubis index e1d596e..b6330bc 100644 --- a/controller/hk_trigger.anubis +++ b/controller/hk_trigger.anubis @@ -15,8 +15,12 @@ public type HK_Trigger_Result: . public type HK_Trigger_Type: + before_create, + after_create, before_update, - after_update + after_update, + before_delete, + after_delete . public type HK_Trigger: @@ -28,8 +32,12 @@ public type HK_Trigger: public type HK_Trigger_Set: hk_trigger_set( + Var(List(HK_Trigger)) before_create, //must be called before create the requested + Var(List(HK_Trigger)) after_create, //must be called after create the requested Var(List(HK_Trigger)) before_update, //must be called before update the requested - Var(List(HK_Trigger)) after_update //must be called after update the requested + Var(List(HK_Trigger)) after_update, //must be called after update the requested + Var(List(HK_Trigger)) before_delete, //must be called before delete the requested + Var(List(HK_Trigger)) after_delete //must be called after delete the requested ) . -- libgit2 0.21.4