Comment on page
Clear needs your model to define a primary key column. By default, Clear can handle properly
As time of writing this manual, compound primary keys are not handled properly.
Clear offers a built-in
primary_keyhelper which will define your primary key without hassle:
self.table = "products"
primary_key name: "product_id", type: :uuid
nameis the name of your column in your table. (Default:
typeis the type of the column in your table. Set to (Default:
- By default, types can be of type
Note than primary_key directive in the model class is just a fast way of writing:
column id : Int64, primary: true, presence: false
The primary key name is ID, of type bigint and it won't check the presence on save because it has default value
In case of
uuid, Clear will generate a new
uuidat every new object creation before inserting it into the database.