yakiire

command module
v0.0.0-...-f5b5bba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2019 License: MIT Imports: 1 Imported by: 0

README

🔥🔥🔥 yakiire 🔥🔥🔥

CircleCI

yakiire (yaki-ire; 焼入れ) is a CLI to manage and operate data on GCP Firestore.

THIS IS THE ALPHA VERSION !!

Contents

Installation

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
yakiire get -c <collection name> <document ID>

e.g.

$ 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 to check the result from the command.

$ yakiire get -c products 002VQIDE4D | tail -n 1 | jq .

{
  "Attributes": {
    "color": "red",
    "size": "100"
  },
  "CategoryIDs": [
    "1",
    "2",
    "3"
  ],
  "ID": "002VQIDE4D",
  "Name": "Test Product"
}
Query
yakiire query --collection products \
    --where '{"Path": "Attributes.size", "Op": ">", "Value": 0}' \
    --where '{"Path": "Attributes.color", "Op": "==", "Value": "red"}' \
    --limit 1

e.g.

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
yakiire add -c <collection name> <json string>

e.g.

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
yakiire delete -c <collection name> <document ID>

e.g.

yakiire delete --collection products 002VQIDE4D

# No output is returned if the document is deleted or does not exist (default firestore behavior)

TODOs

Set
yakiire set -c <collection name> <query>

For development

Run tests
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.

Documentation

Overview

Copyright © 2019 mookjp <mookjpy@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL