Track changes to your models. See who has looked at or changed the models data and how it was changed.
npm install sequelize-tracker
How to use
var Sequelize = ;var Tracker = ;
Create a sequelize instance and your models, e.g.
var sequelize = '' '' ''dialect: 'postgres';
2) Add the tracker feature to your models
var Target = sequelize;;
3) Use it in your queries
destroy queries are logged by default. You just need to pass
trackOptions object with
user_id in options.
update can be set to ignore changes by passing
track: false in
find does not logged. You will need explicitly to pass
track: true in
Only update has a bulk update trigger. If you want to log other bulk operations. Use
By default there will be no user metadata saved. If you want to log this, pass all metadata information you want to
Sequelize doesn't do deep equal checks. This means that when using
changed isn't triggered on fields that are data type
Array. You have to use the setter
Alternatively you can use
model.update() which uses
4) How it is logged
Tracker creates a table and a model. Model is affixed with
Log and table is affixed with
Changes object example:
field: 'name'value: 'John'previousValue: 'Michael'
The default syntax for
Tracker(model, sequelizeInstance, options)
whereas the options are listed here (with default value).
// By default it keeps all logs after tracked item is deletedpersistant: truechanges: 'update'
['update', 'create', 'delete'] are supported.
update cannot be excluded.
The MIT License (MIT)
Copyright (c) 2018 Sergei Liski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.