Models
A model is the single, definitive source of information about your data. It contains the essential fields and behaviours of the data you're storing. Generally each models maps to a single database table. It is a class with fields that describe data you're storing in your database. You use models to abstract away the database specific code.
Define a model#
To define a model,
- extend djorm/models/DatabaseModel
- define fields
- register the model.
Quick example#
In this example we create a Person with firstName and lastName:
Following will apply once the migrations feature is finished.
The above Person model would create database table like this:
Technical notes#
- The table name is derived from the model name
- Unlike Django, the id field is not automatically added to the model
- The SQL is generated using MySQL driver. To use other drivers, configure your databases.