Small CLI tool to store/retrieve key/value pairs in GCP Firestore(in Datastore mode).
Accessing the Firestore will require the Service Account with 'Cloud Datastore User' Role granted. Download the Service Account key file and store it as credentials.json
.
export GOOGLE_APPLICATION_CREDENTIALS="credentials.json"
export GOOGLE_PROJECT_ID="my_project123"
There are 3 commands implemented: get
, put
, and clean
.
The syntax is following:
./firestorekv put <KIND> <KEY> <VALUE>
For example:
./firestorekv put numbers the_number 42
The syntax is following:
./firestorekv get <KIND> <KEY>
For example:
./firestorekv get numbers the_number
All key/value pairs get timestamp field during creation/update. This allows to cleanup old entities.
The syntax is following:
./firestorekv clean <TIMESTAMP>
For example:
week_ago=$(date --date="7 days ago" +%s)
./firestorekv clean passwords $week_ago