A package for MongoDB duplication
npm install duplicate-mongo-db 
A simple and efficient npm package for duplicating data between MongoDB databases, even within the same URI.
To install the package, use npm:
``bash`
npm install duplicate-mongo-db
Or with yarn:
`bash`
yarn add duplicate-mongo-db
Here's how you can use this package in your project:
`javascript
const duplicateMongoDB = require('duplicate-mongo-db');
const options = {
sourceURI: 'mongodb://sourceURI',
targetURI: 'mongodb://targetURI',
sourceDBName: 'sourceDatabase',
targetDBName: 'targetDatabase',
};
duplicateMongoDB(options)
.then(() => {
console.log('Duplication successful!');
})
.catch((error) => {
console.error('Duplication failed:', error);
});
`
- sourceURI: The connection string for the source MongoDB server. Can be the same as targetURI.targetURI
- : The connection string for the target MongoDB server. Can be the same as sourceURI.sourceDBName
- : The name of the source MongoDB database to be duplicated.targetDBName
- : The name of the target MongoDB database where the data will be duplicated.
`javascript
const options = {
sourceURI: 'mongodb://localhost:27017',
targetURI: 'mongodb://localhost:27017',
sourceDBName: 'sourceDatabase',
targetDBName: 'targetDatabase',
};
duplicateMongoDB(options)
.then(() => {
console.log('Database duplicated successfully!');
})
.catch((error) => {
console.error('Duplication failed:', error);
});
`
`javascript
const options = {
sourceURI: 'mongodb://sourceURI',
targetURI: 'mongodb://targetURI',
sourceDBName: 'sourceDatabase',
targetDBName: 'targetDatabase',
};
duplicateMongoDB(options)
.then(() => {
console.log('Database duplicated successfully!');
})
.catch((error) => {
console.error('Duplication failed:', error);
});
``
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the ISC License - see the LICENSE file for details.