tylerjpeterson / sequelize-history Goto Github PK
View Code? Open in Web Editor NEWCreates a revision history for instances of a given Sequelize model.
Creates a revision history for instances of a given Sequelize model.
I have noticed that modelId
is removed from rows (created on update) in history table when that row is deleted from the original table. Why is that? Is it a bug?
If I do a save() operation on a model like so
Ticket.prototype.setState = function(status) {
this.status = status;
return this.save({fields:['status']});
}
the modelid field gets not set in the history table. If I add the id field in fields, everything is fine. Just to let you know.
I use UUID as the primary key in all my tables, so this is not compatible with this library because the modelID column is hardcode to only be INTEGER.
#7 Will check the type of the primary key in the source table as it is creating the History table.
Model.hook() is not a method of the sequelize model instance. It should be 'addHook'.
Changing this.model.hook
and this.modelHistory.hook
to this.model.addHook
and this.modelHistory.addHook
respectively in the hookup()
in index.js method fixes this.
Unless I'm missing something of course in how i'm supposed to use the package!!
From README.md:
NOTE - if
authorFieldName
is set,hasMany
andbelongsTo
relationships will be created between the history model and the target model. This is to ensure that constraints are not enforced in creating the associations.
Can you clarify this? Which constraints would be a problem, and why? Also, why does this matter only when there is an author field? Why not create these associations always? It would be great to be able to do MyModel.findAll({ include: "revisions" })
out of the box. I don't see what the author field has anything to do with this.
Hi.
It will be good if you will add ability to change sequelize options for history table.
Its only 2 lines of code.
line 49:
change in sequelize.define
in constructor
from:
sequelize.define(
this.modelName,
this.setAttributes(),
{});
to:
sequelize.define(
this.modelName,
this.setAttributes(),
this.options.modelOptions);
and SequelizeHistory.DEFAULTS
in line 269 into:
SequelizeHistory.DEFAULTS = {
// Object used to get access to sequelize table settings
modelOptions: {},
// rest of options...
It will just add access into sequelize table options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.