Model

What is model?

Model is representation of table (or collection) in database. It can be accesed as typical java object. Every CRUD operation can be done just with calling RatORM initalized method responsible for its role (like delete - .delete)

Why should i use model instead of normal query's?

ORM (Object Relation Mapping) is way more comfortable and secure then using query's. Everything you need to do is just modify object and call method. Simple as that

How i am supposed to create model?

Creating model is just creating new class with (only) fields using Modelon every field and one on class.

Example

@Model(tableName="example-table")
public class ExampleModel extends BaseModel {
    @ModelField(isPrimaryKey = true)
    int id;
    @ModelField
    String username = "default value";
    // Custom table name
    @ModelField(name="test")
    String oneName;
}

Last updated