Model¶
Model could not be created directly. To access this API, you need to invoke the newModel method from ilorm. And create your own child model.
(static) Model.query()¶
Create a Query instance targeting the current Model.
const query = Model.query();
Example of query
UserModel is a Model with a numberField : weight
.
const user = async UserModel.query()
.weight.min(80)
.findOne();
(static)(async) Model.getById()¶
Get an instance of the model by it's Id.
const modelInstance = await Model.getById(id);
Parameter | Type | Default | Description |
---|---|---|---|
id | Mixing | The id of the instance to get. |
(static) Model.id(ids)¶
Create a model Id linked with the ids parameter.
Parameter | Type | Default | Description |
---|---|---|---|
ids | Mixing | Create a Model_Id linked with ids |
(async) Model.save()¶
Save the current instance into the database. - If the instance exists, it will make an update with the updated field only. - If the instance does not exists. It will create the instance into the database.
await modelInstance.save();
(async) Model.remove()¶
Remove the current instance from the database.
await modelInstance.remove();