Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@awkward/sequelize-reassociate
Advanced tools
A simple abstraction for Sequelize to reassociate a models associations if it ever were to be destroyed.
A simple abstraction for the Sequelize to reassociate a models associations if it ever were to be destroyed.
Sequelize-reassociate basically moves a models associations to a provided record if the parent model were to be destroyed. For example, if a User
model owns many Comment
s, we can transfer the Comment
s to a Ghost-user (like GitHub does) so the context of the conversation can be preserved. It currently only works for HasMany
associations.
npm install @awkward/sequelize-reassociate --save
const reassociate = require('@awkward/sequelize-reassociate');
index.js
file (or wherever you initialize Sequelize) just call the function and pass in your initialized sequelize instance. Make sure the models already have been initialized at this point. // pass in the reference to sequelize after models have been initialized
reassociate(sequelize);
const User = sequelize.define('user', {
// snip ...
},
{
classMethods: {
associate: function(models) {
User.hasMany(models.Comment);
},
reassociate: function() {
// if the User gets destroyed, its Comments go to User with id 1
return {
Comments: 1,
};
}
}
}
});
Basically the heart is in the reassociate()
method. The return value should be an object containing the association (either the Model name or the reference when using as
in the association) and the value is the foreign key pointing to the new owner.
FAQs
A simple abstraction for Sequelize to reassociate a models associations if it ever were to be destroyed.
The npm package @awkward/sequelize-reassociate receives a total of 1 weekly downloads. As such, @awkward/sequelize-reassociate popularity was classified as not popular.
We found that @awkward/sequelize-reassociate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.