1.0.6 • Published 1 year ago

mongosynctosql v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

mongosynctosql

================

This package, mongosynctosql, is a simple utility to synchronize data from a MongoDB database to a MySQL database. It is built using Node.js and the mongodb and mysql npm packages.

Installation

Usage

To use this package, you will need to provide the following configuration:

  • mongoConfig: an object containing the MongoDB connection information, including the Mongo URL, database name, and collection name.
  • mysqlConfig: an object containing the MySQL connection information, including the host, user, password, database name, and table name.
  • fieldsThatYouMigrateToMySqlFromMongo: an array of objects, each containing the field name conversion, the field name in MongoDB, and the conversion type.

Here is an example of how to use this package:

const syncDataFromMongoToMySQL = require('mongosynctosql');

const mongoConfig = {
    mongoUrl:"yourmongoconnectionstring",
    mongoDbName:"yourmongodbname",
    mongoCollectionName:"yourmongocollectionname"
}

const mysqlConfig = {
    mysqlConfiguration:{
        host: 'host',
        user: 'username',
        password: 'yourpassword',
        database: 'yourdbname'
      },
    mySqlTableName:"yourtablename"
}

const fieldsThatYouMigrateToMySqlFromMongo = [
    {
        fieldNameConversion:"id",
        fieldName:"_id",
        conversionType:"String"
    },
    {
        fieldName:"name",
        conversionType:"String"
    },
    {
        fieldName:"speciality",
        conversionType:"String"
    }
]

syncDataFromMongoToMySQL(mongoConfig, mysqlConfig,fieldsThatYouMigrateToMySqlFromMongo,numberOfDocuments)
 .then(() => {
    console.log('Data synchronization completed successfully');
  })
 .catch((err) => {
    console.error('Error during data synchronization:', err);
  });
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago