Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sequelize-data-sync

chadthomas64MIT1.0.7-b

Data Migration / Comparison Library for Sequelize

sequelize, data, sync, migration, compare, comparison, migrate, migration, migrations, migrate data, data migrate, migrate database, database migrate, database migration, database migrations, data migration, data migrations, migrate mysql, mysql migration, mysql migrate, mysql, datasource, database, compare, comparison

readme

sequelize-data-sync

  • transfer sequelize db data from one model to another

use

SequelizeDataSync.syncData(
    sourceModel,
    targetModel,
    {    
        pivotKey: 'myPropertyName',
        /*
            default: 'id'
            (optional) Default pivot key
        */

        sourcePivotKey: 'myPropertyName',
        targetPivotKey: 'myPropertyName',
        /*
            (optional) Override pivotKey for a specific model
        */

        include: {
            'singularRelationName': {
                pivotKey: 'otherProperty',
                sourcePivotKey: 'otherProperty',
                targetPivotKey: 'otherProperty'
            },
            'singularRelationName': 'otherProperty',
            'singularRelationName': true,
            ....
        },
        /*
            default: {}
            (optional)
            Only goes one level deep.
            Will establish association with BelongsTo / BelongsToMany relationsßß
            will create new records (if needed) for hasOne / hasMany relations

        */

        compareOnly: false,
        /*
            default: false
            (optional)
            Only fire callbacks, don't migrate data
        */

        /****
        ***** Callbacks
        ****/

        // All callbacks are optional

        onNewRecord: function(record) {},

        onUpdateRecord: function(record, key, newValue, oldValue, isNewRecord) {},

        onDeleteRecord: function(record) {},

        onNew< singular relation name >: function(relationRecord, record, singularRelationName) {},
        onNewRelated: function(relationRecord, record, singularRelationName) {},

        onUpdate< singular relation name >: function(relationRecord, key, oldValue, newValue, record, isNewRecord, singularRelationName) {},
        onUpdateRelated: function(relationRecord, key, oldValue, newValue, record, isNewRecord, singularRelationName) {},
        /*
            Only gets called for a hasOne or hasMany relation
        */

        onDelete< singular relation name >: function(relationRecord, record, singularRelationName) {},
        onDeleteRelated: function(relationRecord, record, singularRelationName) {}
    }
);

Roadmap: Testing will be implemented soon, along with updated, more clear documentation

License

MIT