https://github.com/vladholubiev/mongo-move
Move docs between MongoDB collection, matching criterias, and w/ optional transformer
https://github.com/vladholubiev/mongo-move
mongodb node-module npm-package
Last synced: about 1 month ago
JSON representation
Move docs between MongoDB collection, matching criterias, and w/ optional transformer
- Host: GitHub
- URL: https://github.com/vladholubiev/mongo-move
- Owner: vladholubiev
- License: mit
- Created: 2017-10-10T16:05:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-16T15:32:42.000Z (over 4 years ago)
- Last Synced: 2025-02-28T13:22:25.182Z (over 1 year ago)
- Topics: mongodb, node-module, npm-package
- Language: TypeScript
- Homepage: https://stackoverflow.com/a/27041518/2727317
- Size: 148 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# Mongo Move [](https://circleci.com/gh/vladgolubev/mongo-move)  
> Move documents between MongoDB collection. Applying async transforms, optionally.
## Install
```sh
$ yarn add mongo-move
```
## Usage
```js
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
```sh
$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags
```
## License
MIT © [Vlad Holubiev](https://vladholubiev.com)