https://github.com/mookjp/yakiire
yakiire is a small CLI for Firestore
https://github.com/mookjp/yakiire
cli firebase firestore gcp go golang
Last synced: about 1 month ago
JSON representation
yakiire is a small CLI for Firestore
- Host: GitHub
- URL: https://github.com/mookjp/yakiire
- Owner: mookjp
- License: mit
- Created: 2019-06-29T07:27:53.000Z (about 7 years ago)
- Default Branch: develop
- Last Pushed: 2019-07-07T18:22:19.000Z (almost 7 years ago)
- Last Synced: 2025-12-19T20:44:03.461Z (6 months ago)
- Topics: cli, firebase, firestore, gcp, go, golang
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
π₯π₯π₯ yakiire π₯π₯π₯
================================================================================
[](https://circleci.com/gh/mookjp/yakiire)
`yakiire` (yaki-ire; ηΌε
₯γ) is a CLI to manage and operate data on GCP [Firestore](https://firebase.google.com/docs/firestore).
**THIS IS THE ALPHA VERSION !!**
## Contents
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Get](#get)
- [Query](#query)
- [TODOs](#todos)
- [Set](#set)
- [For development](#for-development)
- [Run tests](#run-tests)
## Installation
```bash
go get github.com/mookjp/yakiire
```
## Configuration
`yakiire` needs environment variables:
| ENV | value | required |
|-----|-------|----------|
| YAKIIRE_FIRESTORE_PROJECT_ID | Firestore project ID | Yes |
| YAKIIRE_GOOGLE_APPLICATION_CREDENTIALS | GCP's credential file path | No |
If `YAKIIRE_GOOGLE_APPLICATION_CREDENTIALS` was not set, `yakiire` uses `GOOGLE_APPLICATION_CREDENTIALS` to access to Firestore.
## Usage
### Get
```bash
yakiire get -c
```
e.g.
```bash
$ yakiire get -c products 002VQIDE4D
# it shows a doc in JSON format
{"Attributes":{"color":"red","size":"100"},"CategoryIDs":["1","2","3"],"ID":"002VQIDE4D","Name":"Test Product"}
```
It is handy to use [jq](https://firebase.google.com/docs/firestore) to check the result from the command.
```bash
$ yakiire get -c products 002VQIDE4D | tail -n 1 | jq .
{
"Attributes": {
"color": "red",
"size": "100"
},
"CategoryIDs": [
"1",
"2",
"3"
],
"ID": "002VQIDE4D",
"Name": "Test Product"
}
```
### Query
```bash
yakiire query --collection products \
--where '{"Path": "Attributes.size", "Op": ">", "Value": 0}' \
--where '{"Path": "Attributes.color", "Op": "==", "Value": "red"}' \
--limit 1
```
e.g.
```bash
yakiire query --collection products \
--where '{"Path": "Attributes.size", "Op": ">", "Value": 0}'
# it shows docs in line-delimited JSON format
{"Attributes":{"color":"red","size":100},"CategoryIDs":["1","2","3"],"ID":"1","Name":"Test Product"}
{"Attributes":{"color":"red","size":200},"CategoryIDs":["1","2","3"],"ID":"2","Name":"Another Test Product"}
yakiire query --collection products \
--where '{"Path": "Attributes.size", "Op": ">", "Value": 0}' \
--limit 1
# limit to 1 result
# default number of limit is 20
{"Attributes":{"color":"red","size":100},"CategoryIDs":["1","2","3"],"ID":"1","Name":"Test Product"}
yakiire query --collection products \
--where '{"Path": "Attributes.size", "Op": ">", "Value": 0}' \
--where '{"Path": "CategoryIDs", "Op": "array-contains", "Value": "1"}' \
--limit 1
# multiple where conditions
{"Attributes":{"color":"red","size":100},"CategoryIDs":["1","2","3"],"ID":"1","Name":"Test Product"}
```
### Add
```bash
yakiire add -c
```
e.g.
```bash
yakiire add --collection products '{"Attributes":{"color":"red","size":"100"},"CategoryIDs":["1","2","3"],"ID":"002VQIDE4D","Name":"Test Product"}'
# it shows the doc in JSON format if added successfully
{"Attributes":{"color":"red","size":"100"},"CategoryIDs":["1","2","3"],"ID":"002VQIDE4D","Name":"Test Product"}
```
### Delete
```bash
yakiire delete -c
```
e.g.
```bash
yakiire delete --collection products 002VQIDE4D
# No output is returned if the document is deleted or does not exist (default firestore behavior)
```
## TODOs
### Set
```bash
yakiire set -c
```
## For development
### Run tests
```bash
FIRESTORE_EMULATOR_HOST=localhost:8080 make test
```
Test needs running Firestore emulator and it can be run with `docker-compose`.
in `Makefile`, `test` will start firestore emulator container before it starts tests.