Tables - Flaarum Tutorials
A table is a store of similar information. In flaarum a table structure (or definition) is enforced. This helps checks for typing errors and reduces bugs in a setup.
Supported Data Types
The following datatypes are supported in flaarum:
- bool - saved as either 't' or 'f'.
- float - maps to the float64 golang type
- int - maps to the int64 golang type
- string - an indexed string - not more than 220 characters
- text - an unindexed string - infinite size
Table Defintion Statements
The syntax is very different from SQL. The syntax also does not support comments.
table: users fields: firstname string required surname string required email email unique required dob date biography text ::
- The primary key is automatically created. It is of type `int` and is named `id`. Also it is autoincremented and it is unique.
- Each section is ended with '::' and is compulsory even if only the fields section is present.
table: grades fields: userid int required grade int required creation_dt datetime remarkid int required creation_year int required :: foreign_keys: userid users on_delete_delete remarkid remarks on_delete_delete ::
- Foreign keys in Flaarum only supports linking against the `id` of a table.
- A foreign_key part takes either an on_delete_delete or an on_delete_restrict with on_delete_restrict being the default.