
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
js-migrations
Advanced tools
npm install js-migrations
or kanso
A migration is an object with a version
and one or both of up
and down
functions, which migrate up to, or down from this version respectively. For example:
var myMigration = {
version: '1.2.5',
up: function(obj, callback) {
var num = parseInt(obj.a);
if (isNaN(num)) {
return { error: 'a is not a number' };
} else {
obj.a = num
return { error: false, result: obj };
}
},
down: function(obj, callback) {
obj.a = obj.a + '';
return { error: false, result: obj };
}
};
Version should be unique between migrations or there will be no way to tell which set of migrations have been run.
var migration = require('js-migrations');
var migrated = migration.migrate(
{ a: '42' },
[ myMigration ],
{ from: '1.1.5', to: '2.1.3' }
);
if (migrated.err) throw migrated.err;
var obj = migrated.result;
If from
or to
is omitted above there will be no lower or upper limit respectively. If both are omitted all migrations will be run. If from
is greater than to
then the down migrations are run.
All versions must follow the semver format.
FAQs
Migrate a JavaScript object
The npm package js-migrations receives a total of 3 weekly downloads. As such, js-migrations popularity was classified as not popular.
We found that js-migrations 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.