Start by registering the provider inside start/app.js
file.
const providers = [
'adonis-audit/providers/AuditProvider'
]
Add the following to your model's boot
method:
class MyModel extends Model {
boot () {
super.boot()
this.addTrait('@provider:Auditable')
}
}
This you can start using as follows:
// create
await MyModel.audit().create(/** model data **/)
// update
await MyModel.audit().update(/** model data **/)
// delete
await MyModel.audit().delete()