0.4.1 • Published 4 years ago

mongodb-bulk-delete v0.4.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

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

Thu May 14 2020 22:36:06 GMT+0000 (Coordinated Universal Time) Connected successfully to server

  

Thu May 14 2020 22:36:06 GMT+0000 (Coordinated Universal Time) Getting total documents...

Thu May 14 2020 22:36:19 GMT+0000 (Coordinated Universal Time) Total Documents matching query: 4471381

  

Documents Deleted: 4471396 Progress: 100% Thu May 14 2020 22:51:56 GMT+0000 (Coordinated Universal Time)

Successfully completed!

  

{ documentsDeleted: 4471396, timeTaken: "15m 37s" }

Note

The total number of matching documents at the start of the script and the total documents deleted might vary as decords may be added/removed by other clients while the script is running.

Configs

NameConfigDefault
uri'mongodb://localhost:27017'Standard mongodb connection uri
dbDatabase name
collectionquery object
removalBatchSize1000Number of documents deleted in a batch

Things to ensure before running the script on a live production server

  • proper indexes are in place to quickly get the total number of documents else it might bog down the database server

  • the script runs at non-peak hours

0.4.1

4 years ago

0.4.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago