
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
sequelize-transactions
Advanced tools
Give Sequelize transactions ability
Example Usage:
var Sequelize = require('sequelize');
var useTransaction = require('sequelize-transactions');
var db = null; // sequelize instance
function connectDB(callback) {
var sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'sqlite',
storage: dbPath + '/mydb.db',
logging: console.log // false
})
// Create and attach new Transaction for this adapter
useTransaction(sequelize);
// Init Models
// ...
// if (callback) callback(sequelize);
db = sequelize;
}
function view_myViewEndPoint() {
var self = this;
var name = this.get.name || '';
var type = this.get.type || '';
// You might also wait transactions to prevent deadlock in some database (ie: SQLite)
// using waitTransaction(). Set first param of start() = true
db.trx.start(true, function(commit, rollback) {
db.models.Service.find({where: {name: name, type: type}})
.success(function(service) {
if (service) {
db.models.Queue.count({where: ['date(time)=date() AND serviceId=?', service.id]})
.success(function(count) {
db.models.Queue.create({
start: new Date(),
serviceId: service.id,
queueNo: utils.padDigits(count, 3),
})
.success(function(record) {
commit(function(error) {
if (!error)
self.content('OK');
else
self.content('ERROR');
});
})
.error(function(error) {
rollback();
self.content('ERROR');
});
})
.error(rollback);
} else {
rollback();
self.content('SERVICE NOT FOUND');
}
});
});
}
FAQs
Sequelize Transactions
The npm package sequelize-transactions receives a total of 16 weekly downloads. As such, sequelize-transactions popularity was classified as not popular.
We found that sequelize-transactions 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.