mongo-move
v5.1.2
Published
> Move documents between MongoDB collection. Applying async transforms, optionally.
Downloads
12,762
Readme
Mongo Move
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