6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Firebase-CLI ( Realtime Database 操作) #firebase

Last updated at Posted at 2018-05-09

公式サイト手順

以下を見れば全てできるようになっています。
Firebase CLI リファレンス  |  Firebase

ここでは、備忘録としていくつか

ログインしたFirebaseのプロジェクト一覧を参照する


 $ firebase list
┌────────────────────┬───────────────────────┬─────────────┐
│ Name               │ Project ID / Instance │ Permissions │
├────────────────────┼───────────────────────┼─────────────┤
│ xxxxxxTrainer      │ xxxxxxtrainer         │ Owner       │
├────────────────────┼───────────────────────┼─────────────┤
│ xxxxFortuneTelling │ xxxxfortunetelling    │ Owner       │
├────────────────────┼───────────────────────┼─────────────┤
│ xxxxxxxxxmodular2  │ xxxxxxxxxmodular2     │ Owner       │
├────────────────────┼───────────────────────┼─────────────┤

Firebaseのどのプロジェクトを使うか

$ firebase use --add
? Which project do you want to add? xxxxxxxxxmodular2
? What alias do you want to use for this project? (e.g. staging) firefunctions

利用中のFirebaseプロジェクト

$ firebase use
Active Project: firefunctions (xxxxxxxxxmodular2)

Project aliases for /Users/bohebohechan/Documents/gitLab/FirstFourNotes/lab/ionic/ionic-firebase:

* firefunctions (xxxxxxxxxmodular2)

Realtime Databseにデータをセットする

jsonで登録データを作成する


$firebase database:set /users users.json
? You are about to overwrite all data at https://xxxxxxxxxmodular2.firebaseio.com/users. Are you sure? Yes

✔  Data persisted successfully

View data at: https://console.firebase.google.com/project/xxxxxxxxxmodular2/database/data/users

で、表示されたURLで見ると。/usersの配下にデータが登録されている

Realtime Databseにデータを取得する


 $ firebase database:get /users | jq .
[
  {
    "address": {
      "city": "Gwenborough",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      },
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "zipcode": "92998-3874"
    },
    "company": {
      "bs": "harness real-time e-markets",
      "catchPhrase": "Multi-layered client-server neural-net",
      "name": "Romaguera-Crona"
    },
    "email": "Sincere@april.biz",
    "id": 1,
    "name": "Leanne Graham",
    "phone": "1-770-736-8031 x56442",
    "username": "Bret",
    "website": "hildegard.org"
  }

Realtime Databseからデータ削除

$ firebase database:remove /users
? You are about to remove all data at https://xxxxxxxxxmodular2.firebaseio.com/users. Are you sure? Yes
✔  Data removed successfully

CloudFireStoreについては、deleteコマンドしか用意されていない模様(2018/5/9現在)

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?