Lookup Trigger
Lookup trigger manipulates with the content of the lookup.
It means that it can add (set), increment (add), decrement (sub) and remove (delete) an entry in the lookup.
The entry is identified by a key
, which is a unique primary key.
Example of the trigger that adds an entry to the lookup user_list
:
trigger:
- lookup: user_list
key: !ITEM EVENT user.name
set:
event.created: !NOW
foo: bar
Example of the trigger that removes an entry from the lookup user_list
:
trigger:
- lookup: user_list
delete: !ITEM EVENT user.name
Example of the trigger that increments a counter (field my_counter
) in the entry of the lookup user_list
:
trigger:
- lookup: user_list
key: !ITEM EVENT user.name
add: my_counter
Example of the trigger that decrements a counter (field my_counter
) in the entry of the lookup user_list
:
trigger:
- lookup: user_list
key: !ITEM EVENT user.name
sub: my_counter
For both add
and sub
, the counter field name can be omitted. Hence the default attribute _counter
will be used implicitly:
trigger:
- lookup: user_list
key: !ITEM EVENT user.name
sub:
If the counter field does not exist, it is created with the default value of 0.
!! note
Lookup entries can be accessed from the declarative expressions by `!LOOKUP.GET` and `!LOOKUP.CONTAINS` entries.