Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

mongosynctosql

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongosynctosql

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

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

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);
  });

Keywords

mongo

FAQs

Package last updated on 21 May 2024

Did you know?

Socket

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.

Install

Related posts