
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
sequelize-model-comments
Advanced tools
Comments support for your sequelize models. Record the user who created the comment. When used along with sequelize-paper-trail, annotates revisions with a user supplied comment.
npm install --save sequelize-model-comments
Note: the current test suite is very limited in coverage.
Sequelize Model Comments assumes that you have already set up your Sequelize connection, for example, like this:
var Sequelize = require('sequelize');
var sequelize = new Sequelize('database', 'username', 'password');
then adding Sequelize Model Comments is as easy as:
var ModelComments = require('sequelize-model-comments').init(sequelize, options);
ModelComments.defineModels({});
which loads the Model Comments library, and the defineModels() method sets up a Comments table.
Note: If you pass userModel option to init in order to enable user tracking, userModel should be setup before defineModels() is called.
Then for each model that you want to keep a model comments you simply add:
Model.enableModelComments();
var Sequelize = require('sequelize');
var sequelize = new Sequelize('database', 'username', 'password');
var ModelComments = require('sequelize-model-comments').init(sequelize, options || {});
ModelComments.defineModels();
var Post = sequelize.define('Post', {
title: Sequelize.STRING,
content: Sequelize.STRING,
});
Post.enableModelComments();
There are 2 steps to enable user tracking, ie, recording the user who created a comment.
userModel option to init, with the name of the model which stores users in your application as the value.var options = {
/* ... */
userModel: 'users',
};
sequelize-model-comments by sequelize options.Post.update({
/* ... */
comment: 'This attribute will be used to create a comment which annotates the revision'
}, {
userId: user.id
}).then(() {
/* ... */
});
Model Comments supports various options that can be passed into the initialization. The following are the default options:
// Default options
var options = {
commentModel: 'Comment',
UUID: false,
underscored: false,
underscoredAttributes: false,
defaultAttributes: {
documentId: 'documentId',
model: 'model'
},
};
| Option | Type | Default Value | Description |
|---|---|---|---|
| [debug] | Boolean | false | Enables logging to the console. |
| [commentModel] | String | 'Comment | Name of the model that keeps the comments. |
| [UUID] | Boolean | false | The [commentModel] has id attribute of type UUID for postgresql. |
| [underscored] | Boolean | false | The [commentModel] has 'createdAt' and 'updatedAt' attributes, by default, setting this option to true changes it to 'created_at' and 'updated_at'. |
| [underscoredAttributes] | Boolean | false | The [commentModel] has a [defaultAttribute] 'documentId' by default, setting this option to true changes it to 'document_id'. |
| [defaultAttributes] | Object | { documentId: 'documentId', model: 'model' } | |
| [userModel] | String | Name of the model that stores users in your. |
Please use:
git checkout -b my-new-feature)git commit -am 'Added some feature')git push origin my-new-feature)© Lijo Antony – @lijo_ – lijozom@gmail.com
Distributed under the MIT license. See LICENSE for more information.
https://github.com/lijoantony/sequelize-model-comments
This project was inspired by and derived from:
FAQs
Add comments to your Sequelize models.
We found that sequelize-model-comments demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.