Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 564 Bytes

instructions.md

File metadata and controls

35 lines (26 loc) · 564 Bytes

Register provider

Start by registering the provider inside start/app.js file.

const providers = [
  'adonis-audit/providers/AuditProvider'
]

Making a model auditable

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()