Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@rematter/sequelize-paranoid-delete
Advanced tools
sequelize-paranoid-delete enables onDelete when using paranoid mode
sequelize-paranoid-delete enables onDelete when using paranoid mode in sequelize
The following example uses a MySql database through sequelize and persists the migration data in the database itself through the sequelize storage.
// index.js
const { Sequelize } = require('sequelize');
const { Umzug, SequelizeStorage } = require('umzug');
const { queryInterfaceDecorator } = require('sequelize-paranoid-delete');
const sequelize = new Sequelize({ dialect: 'mysql', storage: './db.mysql' });
const umzug = new Umzug({
migrations: { glob: 'migrations/*.js' },
// as simple as the following line
context: queryInterfaceDecorator(sequelize.getQueryInterface()),
storage: new SequelizeStorage({ sequelize }),
logger: console,
});
// migrations/00_initial.js
const { Sequelize } = require('sequelize');
async function up({ context: queryInterface }) {
await queryInterface.createTable('resources', {
id: {
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
userId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
},
// here we specify the behavior
onDelete: 'PARANOID CASCADE',
}
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
deletedAt: {
type: Sequelize.DATE,
allowNull: true,
},
});
}
This is going to create a trigger in the users table, when a user gets "deleted", the resource will be marked as deleted as well.
If the table was already created, you can use addColumn as well.
const { Sequelize } = require('sequelize');
async function up({ context: queryInterface }) {
await queryInterface.addColumn('resources', 'userId', {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
},
// here we specify the behavior
onDelete: 'PARANOID CASCADE',
});
}
sequelize-paranoid-delete is available on npm by specifying the correct tag:
npm install @rematter/sequelize-paranoid-delete
OR
yarn add @rematter/sequelize-paranoid-delete
Put configuration options in a file named .spdrc
in your working directory.
The expected structure of the file is the following:
{
"dbname": "",
"schema": "",
"username": "",
"password": "",
"host": "",
"port": "",
"dialect": "mysql",
"allowListTables": null,
"denyListTables": null,
"tenantColumns": null
}
Allow list tables, deny list tables and tenant columns are optional.
First two are for configuring which tables you DO want to scan or you do NOT want to scan (specify only one).
Tenant columns is to prevent scanning relations between tenant foreign keys.
npx sequelize-paranoid-delete
yarn node --inspect-brk ./node_modules/.bin/ts-mocha -p lib.tsconfig.json src/**/*.test.ts
See the LICENSE file
FAQs
sequelize-paranoid-delete enables onDelete when using paranoid mode
The npm package @rematter/sequelize-paranoid-delete receives a total of 0 weekly downloads. As such, @rematter/sequelize-paranoid-delete popularity was classified as not popular.
We found that @rematter/sequelize-paranoid-delete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.