CRUD annotations are used in services to constrain the functionality of fields and boxes in an
INTERFACE-statement. This allows you to minimize the functionality for your users, to design for easy learning.
Each CRUD annotation comes right after a term, so we can always refer to "the term" to which a CRUD annotation belongs. A CRUD annotation constrains the things your user can do with the target atoms and the pairs of its term.
The CRUD-annotation specifies Create, Read, Update, and Delete rights for the term it follows. Capital = allowed, Non-capital = not allowed. CRUD is the default, so if you specify nothing, everything is allowed. The following service definition illustrates this.
INTERFACE Overview : "_SESSION" cRud
[ Students : V[SESSION*Student] cRuD
[ "Student" : I[Student] cRud
, "Enrolled for" : isEnrolledFor cRUD
, "Course" : takes CRUD
, Course : V[SESSION*Course] cRuD -- used for a box
[ "Course" : I cRud -- used for a field
, "Modules" : isPartOf~ -- CRUD is default
, Modules : V[SESSION*Module] cRud
[ "Modules" : I cRuD
, "Course" : isPartOf cRUd
, "Students" : isEnrolledFor~ CRUD
The user interface defined by this service is shown as a screenshot below. Notice that the lowercase r in the annotation of the Students box prevents showing the underlying box. The full CRUD functionality in Course yields 'create' functionality (the green plus-button), 'remove pair' functionality (red minus button), and 'delete atom' functionality (the red trash can button). The lowercase c, u, and d in the Modules box prevents displaying that functionality in the user interface.
Column-oriented layout of a user interface with columns in each row
The next sections give some more detailed information on the run time semantics for CRUD annotations as implemented in Ampersand.
A top-level Update or Create are common in my own scripts, e.g. to create an overview of People and be able to create a new Person:
INTERFACE "People" : V[SESSION*Person] CRud COLS . And update is also possible.
- 1.The red minus is enabled by
U. It unlinks an atom (by deleting a pair from a relation) and leaves the atom alone.
- 2.The red trash bin is enabled by
D. It removes an atom and all pairs in which that atom is used.