mongo-elastic-sync

1.1.4 • Public • Published

mongo-elastic-sync

GitHub package.json version GitHub GitHub Workflow Status npm

🚀 Mongo-Elastic Sync is a Node.js library that provides synchronization between MongoDB and Elasticsearch. Seamlessly sync data changes between MongoDB collections and corresponding Elasticsearch indices.

Installation

npm install mongo-elastic-sync

Usage

const { Sync } = require("mongo-elastic-sync");

const mongoURL = "mongodb://localhost:27017";
const elasticURL = "http://localhost:9200";

const option = {
  prefix: "auto-sync-",
  initialSync: true,
  debug: false,
};

const syncInstance = new Sync(mongoURL, elasticURL, option);

// Initial Sync (Optional)
syncInstance.initialSync();

// Start Continuous Sync
syncInstance.startSync();

Configuration

  • mongoURL (string): MongoDB connection URL.
  • elasticURL (string): Elasticsearch connection URL.
  • option (object):
    • prefix (string, optional): Prefix for Elasticsearch indices. Default is "auto-sync-".
    • initialSync (boolean, optional): Perform an initial sync of existing MongoDB data to Elasticsearch. Default is true.
    • debug (boolean, optional): Enable debug mode for detailed logs. Default is false.

Features

  • 🔄 Initial Sync: Syncs existing MongoDB data to Elasticsearch upon initialization.
  • 🔁 Continuous Sync: Listens for changes in MongoDB collections and updates corresponding Elasticsearch indices.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

Feel free to contribute, report issues, or request features on GitHub.

Package Sidebar

Install

npm i mongo-elastic-sync

Weekly Downloads

6

Version

1.1.4

License

ISC

Unpacked Size

31.3 kB

Total Files

4

Last publish

Collaborators

  • souravj96