Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsumners/mongo-purge
https://github.com/jsumners/mongo-purge
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/jsumners/mongo-purge
- Owner: jsumners
- Created: 2016-11-22T19:50:33.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-16T13:17:12.000Z (almost 8 years ago)
- Last Synced: 2024-09-21T14:12:29.761Z (about 2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# mongo-purge
*mongo-purge* is a CLI utility for purging documents from a MongoDB collection.
It is intended to be used in cron jobs to keep collections of temporary documents
clean of stale documents.Example:
```bash
$ mongo-purge --uri mongodb://mongo.example.com/the_db \
--collection a_collection \
--credentials ./creds.json \
--older-than $(date -v-5M +'%Y-%m-%dT%H:%M:%SZ')
STATUS: ok: yes, deleted: 10
$ # documents created prior to 5 minutes ago have been removed, total: 10 documents
```Currently, the only supported purge method is to purge documents older
than a specified date and time.## Install
`npm install -g mongo-purge`
## Usage
*mongo-purge* requires the following parameters to be used:
+ `--uri `: a fully qualified URI to a MongoDB database.
+ `--collection `: the name of the collection within the database to target
+ `--older-than `: an ISO-8601 format date and time to use as the cutoff,
e.g. '2016-11-22T14:00:00Z'Optionally, the following parameter can also be supplied:
+ `--credentials `: a path to a JSON document containing the credentials
to the database. A credentials document looks like:```json
{
"username": "a-user",
"password": "his-password"
}
```Clearly, this document should have appropriate permissions set; typically `0640`.
## License
[MIT License](http://jsumners.mit-license.org/)