Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

mongo-to-sqs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-to-sqs

Send MongoDB documents to SQS

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

mongo-to-sqs

Send a large number of MongoDB documents to an AWS SQS queue.

Build Status

  • Populates SQS with documents from MongoDB
  • Uses back-pressure to prevent buffering documents in memory
  • Works with very large collections

Install

npm i mongo-to-sqs

Usage

const MongoToSqs = require('mongo-to-sqs');

const loader = new MongoToSqs({
  cursor,         // db.collection.find()
  sqs,            // new AWS.SQS()
  queueUrl,       // the url of the SQS queue
  formatPayload,  // sync function to transform the document into the SQS MessageBody
  concurrency     // number of concurrent SQS requests (default: 2500)
});

loader.start().then(() => console.log('Done.'));

Example

const MongoDB = require('mongodb');
const AWS = require('aws-sdk');
const MongoToSqs = require('mongo-to-sqs');

MongoDB.MongoClient.connect().then(db => {
  
  const cursor = db.collection('my-collection').find();
  
  const sqs = new AWS.SQS({
    accessKeyId: '...',
    secretAccessKey: '...'
  });
  
  const loader = new MongoToSqs({
    cursor,
    sqs,
    queueUrl: 'https://sqs.us-east-1.amazonaws.com/000000000000/my-queue'
  });
  
  loader.start().then(() => console.log('Done.'));

});

License

MIT

FAQs

Package last updated on 25 Aug 2017

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