
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.
@comodinx/sequelize
Advanced tools
@comodinx/sequelize is an adapter promise-based Node.js ORM autodiscover. Based on sequelize 5
@comodinx/sequelize is an adapter promise-based Node.js ORM autodiscover. Based on sequelize 5
$ npm install @comodinx/sequelize
$ git clone https://gitlab.com/comodinx/sequelize.git
$ cd sequelize
$ npm install
const { Database } = require('@comodinx/sequelize');
// For more information of Database connections. See: https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor
const db = new Database({
host: 'localhost',
username: 'myuser',
password: 'mypass',
database: 'mydbname'
});
// Autodiscover models on database
db.discover().then(() => {
return db.models.users.getById(1);
})
db.query(/* YOUR SQL QUERY */).then(/* array */ result => /*...*/).catch(/*...*/);
db.queryOne(/* YOUR SQL QUERY */).then(/* object|undefined */ result => /*...*/).catch(/*...*/);
This function is automatically responsible for commit or rollback (as appropriate).
The commit will be performed once the callback function received as an argument is finished. In case the callback function returns a promise, the commit will be made at the end of this promise.
In case of any failure, a rollback will be performed automatically (even if the commit fails).
db.transaction(/* callback */ transaction => {
return db
.query(/* FIRST SQL QUERY */, { transaction })
.then(/* array */ result => {
return db.query(/* SECOND SQL QUERY */, { transaction }).then(/*...*/);
});
})
.catch(/*...*/);
db.isAlive().then(/* boolean */ alive => /*...*/).catch(/*...*/);
// OR
db.ping().then(/* boolean */ alive => /*...*/).catch(/*...*/);
db.end().then(/*...*/).catch(/*...*/);
const { DataTypes } = require('sequelize');
const { Model } = require('@comodinx/sequelize');
const model = new Model(/* model name */ 'users', /* model definition */ {
columnA: {
type: DataTypes.BOOLEAN,
validate: {
is: ['[a-z]','i'],
max: 23,
isIn: {
args: [['en', 'zh']],
msg: 'Must be English or Chinese'
}
},
field: 'column_a'
},
columnB: DataTypes.STRING,
columnC: 'MY VERY OWN COLUMN TYPE'
} /* , sequelize options */);
const options = {
where: {
id: 1,
deleted_at: {
$is: null
}
},
order: [['id', 'DESC'], ['created_at', 'ASC']],
offset: 10,
limit: 10
};
model.find(options).then(/* array */ models => /*...*/).catch(/*...*/);
// ------------------------------------------------------------------------------------
const options = {
fields: ['id', 'active'],
where: {
OR: {
deleted_at: {
$is: null,
$gt: '2019-06-01 00:00:00'
}
}
}
};
model.find(options).then(/* array */ models => /*...*/).catch(/*...*/);
model.getById(1).then(/* object|undefined */ model => /*...*/).catch(/*...*/);
const options = {
where: {
id: {
$in: [1, 2, 3]
}
}
};
model.getOne(options).then(/* object|undefined */ model => /*...*/).catch(/*...*/);
const options = {
where: {
id: 1
}
};
model.exist(options).then(/* boolean */ exist => /*...*/).catch(/*...*/);
const options = {
where: {
active: 1
}
};
model.count(options).then(/* number */ total => /*...*/).catch(/*...*/);
const data = {
id: null,
active: 1,
created_at: model.literal('NOW()'),
updated_at: null
};
model.create(data).then(/* object */ model => /*...*/).catch(/*...*/);
const data = {
active: 0,
updated_at: model.literal('NOW()')
};
model.update(data, /* ID value */ 1).then(/* object */ model => /*...*/).catch(/*...*/);
// Or update more rows
const data = {
active: 1
};
model.update(data, /* All disactive rows */ 0, /* Reference field name */ 'active').then(/* array */ models => /*...*/).catch(/*...*/);
model.destroy(/* ID value */ 1).then(/* number */ result => /*...*/).catch(/*...*/);
This function is automatically responsible for commit or rollback (as appropriate).
The commit will be performed once the callback function received as an argument is finished. In case the callback function returns a promise, the commit will be made at the end of this promise.
In case of any failure, a rollback will be performed automatically (even if the commit fails).
model.transaction(/* callback */ transaction => {
const options = {
transaction,
where: {
username: 'myusername'
}
};
return model
.exist(options)
.then(exist => {
if (exist) return model.update(data, 'myusername', 'username', { transaction });
return model.create(data, { transaction });
})
.then(result => model.getById(result.id, { transaction }));
})
.catch(/*...*/);
In order to see more concrete examples, I INVITE YOU TO LOOK AT THE TESTS :)
npm install
npm test
FAQs
@comodinx/sequelize is an adapter promise-based Node.js ORM autodiscover. Based on sequelize 5
We found that @comodinx/sequelize 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.