Socket
Socket
Sign inDemoInstall

mongo2elastic

Package Overview
Dependencies
246
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mongo2elastic

Sync MongoDB collections to Elasticsearch


Version published
Maintainers
1
Created

Changelog

Source

0.1.0

  • Initial release.

Readme

Source

Mongo to Elastic

Sync MongoDB to Elasticsearch

import { initSync, crate } from 'mongo2crate'
import { default as Redis } from 'ioredis'
import { MongoClient } from 'mongodb'
import retry from 'p-retry'
import elasticsearch from '@elastic/elasticsearch'

const client = await MongoClient.connect()
const db = client.db()

const elastic = new elasticsearch.Client()

const sync = initSync(
  new Redis(),
  db.collection('myCollection'),
  elastic,
  { omit: ['password', 'unneededStuff'] }
)
// Process change stream events
sync.processChangeStream()
// Run initial scan of collection batching documents by 1000
const options = { batchSize: 1000 }
retry(() => sync.runInitialScan(options))

Keywords

FAQs

Last updated on 17 Aug 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc