项目作者: Jellyvision

项目描述 :
A plugin for adding a log book / revision history / audit / paper trail to a sequelize model.
高级语言: JavaScript
项目地址: git://github.com/Jellyvision/sequelize-logbook.git
创建时间: 2017-09-29T15:49:28Z
项目社区:https://github.com/Jellyvision/sequelize-logbook

开源协议:MIT License

下载


Sequelize-Logbook

A plugin for adding a log book / revision history / audit / paper trail to a sequelize model.

🎛 Usage

When using the models/index.js associate pattern:

my-model.js

  1. const trackRevisions = require('sequelize-logbook')
  2. module.exports = function(sequelize, DataTypes) {
  3. let MyModel = sequelize.define('MyModel', {
  4. ...
  5. classMethods: {
  6. ...
  7. associate: function(){
  8. ...
  9. trackRevisions(MyModel)
  10. }
  11. }
  12. })
  13. }

General use

  1. const trackRevisions = require('sequelize-logbook')
  2. let MyModel = sequelize.define('MyModel', {...})
  3. let AnotherModel = sequelize.define('AnotherModel', {...})
  4. trackRevisions(MyModel)
  5. trackRevisions(AnotherModel)

🐲 whoDunnit / blame / author tracking.

SequelizeRevisions will look against the global sequelize object
for a whoDunnit key. If this key is present, it will save this value
as the author of the revision.
Otherwise, it’ll fall back to process.env.NODE_ENV

  1. const sequelize = new Sequelize(db, user, password, config)
  2. sequelize.whoDunnit = 'yourUserString'

⚠ Caveats

Revisions will not be automatically generated for instances created, deleted, or updated with Bulk actions
If you want revisions generated for Bulk actions, pass individualHooks: true as a sequelize option.

" class="reference-link">🏗 Contributing contributions welcome

📐 Tests

npm run test

✂ Linting

npm run prettier

✨ Inspired by

This library is similar to these other packages, with the addition of:

  1. whoDunnit / blame history
  2. Unit tests! 📏

License

Sequelize-logbook is MIT licensed.