A simple tool to transfer data between two MongoDB databases.
Install the package using npm:
npm install mongo-data-transfer
## Usage
Use the package programmatically in your Node.js or TypeScript project.
import { transferData } from "mongo-data-transfer";
const sourceUri = "mongodb://user:pass@source-host:27017/sourceDB";
const destinationUri = "mongodb://localhost:27017/destinationDB";
async function run() {
try {
await transferData(sourceUri, destinationUri);
console.log("Data transfer completed successfully!");
} catch (error) {
console.error("Data transfer failed:", error.message);
}
}
run();
## Features
- ✅ **Easy-to-use API**: Transfer data between MongoDB databases with a single **function** call.
- ✅ **Duplicate Handling**: Automatically skips duplicate records based on `_id`.
- ✅ **Efficient Data Transfer**: Handles large collections without performance issues.
- ✅ **TypeScript Support**: Fully typed with TypeScript for better developer experience.
- ✅ **System Collections Ignored**: Automatically skips `system.*` collections.