Audit models in AdonisJS
Install npm module:
$ adonis install adonis-auditable
Once you have installed adonis-auditable, make sure to register the provider inside start/app.js
in order to make use of it.
const providers = [
'adonis-auditable/providers/AuditableProvider'
]
Add the following to your model's boot
method:
class MyModel extends Model {
static boot () {
super.boot()
this.addTrait('@provider:Auditable')
}
}
This you can start using as follows:
// create
const model = await MyModel.audit().create({name: 'John'})
// update
const model = MyModel.find(1)
await model.audit().update({name: 'Simon'})
// delete
const model = MyModel.find(1)
await model.audit().delete()
- AdonisJS - The web framework used.
SemVer is used for versioning. For the versions available, see the tags on this repository.
- Simon Tong - Developer - simontong
This project is licensed under the MIT License - see the LICENSE file for details.
-
v2.0.2
- Fixed bugs for AdonisJS 4.1.
-
v2.0.1
- Removed need to pass in
ctx
parameters. - Update README and instructions.md files.
- Removed need to pass in
-
v2.0.0
- Removed ctx injection on boot.
ctx
parameters need to be passed in manually now. - Updated README to reflect new changes.
- Added this changelog.
- Removed ctx injection on boot.
-
v1.0.1
- Initial release.