Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

Triggers

stickupkid edited this page Aug 15, 2011 · 1 revision

For more information on SQLite Triggers consider reading this dry article. Anyway the basic idea is that they allow you to do something after a statement has happened i.e. update, insert etc.

For example if you wanted to limit a table of Users to 50 items, then you would build it like the following using the SpodTriggerBuilders. The great thing about the builders is that they allow you to only do the following and because everything is a function it becomes very obvious how to use it (considered chaining).

In this example we want to create a trigger AFTER an INSERT and we want to limit the User table to 50 items and order it by the date column. So any item after the order which is after the 50th row will be deleted.

database.createTrigger(User).after().insert().limit(50, new AscOrderExpression('date'));
Clone this wiki locally