Skip to content

A tool to delete large number of records from mongodb

License

Notifications You must be signed in to change notification settings

kbavi/mongodb-bulk-delete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongodb-bulk-delete

A configurable tool to delete records in bulk while in control.

Installation

> npm i mongodb-bulk-delete

Usage

const  bulkDelete  =  require('mongodb-bulk-delete');
bulkDelete.configure({
	uri: 'mongodb://localhost:27017',
	db: 'test',
	collection: 'user',
	query: { userId: { $gt: 100 } },
	removalBatchSize: 100
});
(async () => {
	const result = await bulkDelete.initialise();
	console.log(result);
})();

Example Output

Connected successfully to server

Getting total documents...
Total Documents matching query: 3221557

Documents Deleted: 3221576 	 Progress: 100%

Successfully completed!

{ documentsDeleted: 3221576, timeTaken: "13m 40s" }

The following options are configurable:

Name Default Description
uri 'mongodb://localhost:27017' Standard mongodb connection uri
db Database name
collection Collection name
query query object
removalBatchSize 1000 Number of documents deleted in a batch

About

A tool to delete large number of records from mongodb

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published