- Development Mode
- File System
- Data Types and Attributes
- Instance and Class Methods
- Model Configuration
Data Types and Attributes
The following data types are currently available:
These will map to the underlying database type if available. If a database doesn’t support a type a polyfill will be used. For example when using an array or json type in MySQL the values will be stringified before being saved.
These properties are also available on an attribute and can be used to enforce various constraints on the data.
Will set a default value on an attribute if one is not supplied when the record is created. The supplied value can also be a
function that stellar will run while creating the record.
Will create a new auto-incrementing attribute. These should always be of type
integer and will not be supported in all datastores. For example MySQL will not allow more than one auto-incrementing
column per table.
Ensures no two records will be allowed with the same value. This is a database level constraint so in most cases a unique index will be created in the underlying datastore.
Will create a simple index in the underlying datastore for faster queries if available. This is only for simple indexes and currently doens’t support compound indexes. For these you will need to create them yourself.
There is currently an issue with adding indexes to string fields. Because the ORM performs its queries in a case insensitive manner we are unable to use the index on a string attribute. There are some workarounds being discussed, but nothing is implemented so far. This will be updated in the near future to fully support indexes on strings.
Will set the primary key of the record. This should be used when
autoPK is set to false.
A special validation property which will only allow values that match a whitelisted set of values.
If supported in the datastore, can be used to define the size of the attribute. For example, in MySQL size can be used with a string to create a column with data type:
Override the attribute name before sending to a datastore. This allows you to have a different interface for interacting with your data at the application layer and the data layer. It comes in handy when integrating with legacy databases. You can have a nice API for your data and still allow the data to be saved in legacy columns.