MySQL MongoDB Migrate
Data migration module for migrating mysql tables to mongodb db collections
Installing
npm install mysql-mongodb-migrate --save
Quick Usage
const MigrationJob = ; let sourceConnectionOptions = host: <MYSQL_HOST> port: <MYSQL_PORT> user: <MYSQL_USER> password: <MYSQL_PASSWORD> ssl: <MYSQL_SSL> //optional (Ex:- 'Amazon RDS');let targetConnectionOptions = host: <MONGODB_ENDPOINT> user: <MONGODB_USERNAME> password: <MONGODB_PASSWORD>; const migrationJob = <MYSQL_DATABASE_NAME> <MYSQL_TABLE_NAME> <MONGODB_DATABASE_NAME> <MONGODB_COLLECTION_NAME> sourceConnectionOptions targetConnectionOptions <MYSQL_READ_LIMIT_PER_ITERATION> <MYSQL_READ_THROUGHPUT>; migrationJob
Adavance Usage
Initialize
const MigrationJob = ; let sourceConnectionOptions = host: <MYSQL_HOST> port: <MYSQL_PORT> user: <MYSQL_USER> password: <MYSQL_PASSWORD> ssl: <MYSQL_SSL> //optional (Ex:- 'Amazon RDS');let targetConnectionOptions = host: <MONGODB_ENDPOINT> user: <MONGODB_USERNAME> password: <MONGODB_PASSWORD>; const migrationJob = <MYSQL_DATABASE_NAME> <MYSQL_TABLE_NAME> <MONGODB_DATABASE_NAME> <MONGODB_COLLECTION_NAME> sourceConnectionOptions targetConnectionOptions <MYSQL_READ_LIMIT_PER_ITERATION> <MYSQL_READ_THROUGHPUT>;
Set dynamodb filter expression - filter when scanning dynamodb
const filterExpression = 'attr1 = val1'; migrationJob;
Set data filter function - filter after scan result - similar to lodash filter
const filterFunction = { return itemattr1 !== null;} migrationJob;
Set data mapper function - similar to lodash map
const mapperFunction = { return mappedAttr1 : itemattr1 mappedAttr2 : itemattr2 } migrationJob;
Run
migrationJob
Testing
npm test