mongo-move

> Move documents between MongoDB collection. Applying async transforms, optionally.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
mongo-move
5.1.2a year ago5 years agoMinified + gzip package size for mongo-move in KB

Readme

Mongo Move CircleCI node (tag)
Move documents between MongoDB collection. Applying async transforms, optionally.

Install

$ yarn add mongo-move

Usage

import {MongoClient} from 'mongodb';
import {moveDocs} from 'mongo-move';

const db = await MongoClient.connect('mongo-url');

await moveDocs({
  fromCollection: db.collection('coll-a'),
  toCollection: db.collection('coll-b'),
  selector: {userId: 'some-user-id'},
  projection: {name: 0},
  transformerFn: async doc => {
    doc.movedAt = new Date();
    return doc;
  },
  chunkSize: 1000,
});

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags

License

MIT © Vlad Holubiev