https://github.com/natlibfi/mongo-cleaner
Mongo database cleaner. Removes all items from collection based on modificationTime time stamp (UTC)
https://github.com/natlibfi/mongo-cleaner
Last synced: about 1 year ago
JSON representation
Mongo database cleaner. Removes all items from collection based on modificationTime time stamp (UTC)
- Host: GitHub
- URL: https://github.com/natlibfi/mongo-cleaner
- Owner: NatLibFi
- License: mit
- Created: 2022-10-14T09:13:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-27T03:44:07.000Z (about 1 year ago)
- Last Synced: 2025-06-29T21:02:54.273Z (about 1 year ago)
- Language: JavaScript
- Size: 1.2 MB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# mongo-cleaner
Mongo database cleaner. Removes all items from collection based on creationTime time stamp (UTC)
**COMPATIBLE: MONGO 4.X**
**NOT COMPATIBLE: MONGO 3.X**
# Usage
## Envs:
* MONGO_URI='mongodb://localhost:43575'
* MONGO_DATABASE_AND_COLLECTIONS='[{"db": "", "collection": "collectionName", "removeDaysFromNow": integer, "removeProtected": boolean, "file": boolean, ("test": boolean)}]'
* db: Database name, "" makes mongo to use default database.
* collection: Database collection name.
* removeDaysFromNow: How many days before "now" is log valid. invalid logs are removed
* removeProtected: Boolean variable for forcing removal of protected items. Defaults false.
* file: Boolean variable to determine file collection cleaning
* test: Boolean variable to determine if test params are to be used on file search. Mongo-memory-server and real mongo wants different types of time variables.
## Debug envs:
* LOG_LEVEL='debug'
* MONGOMS_DEBUG=1
## License and copyright
Copyright (c) 2022-2025 **University Of Helsinki (The National Library Of Finland)**
This project's source code is licensed under the terms of **MIT** or any later version.