VOOZH about

URL: https://qiita.com/muzou/items/ab215e6e9da93926600e

⇱ firestoreにgoogle app script #Firebase - Qiita


👁 Image
13

Go to list of users who liked

17

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@muzou(yasuo watanabe)

firestoreにgoogle app script

13
Last updated at Posted at 2017-11-19

課題

  • アプリのバックエンドにfirebase ( auth / firestore / cloud function ) を使用している
  • その時のマスタデータの扱いにスプレッドシートを使いたい

作戦

  • spread sheet => gas => firestore

APEENDIX

やったこと

GASへライブラリの読み込み

メニューからリソース => ライブラリ => MX2_NUfxVpaA1XPcZ_N-3wWb_Hp7BVbw3 を入力
保存

サービスアカウントの作成

下記のページにアクセスし新規アカウントを作成
https://console.developers.google.com/projectselector/iam-admin/serviceaccounts
※ cloud databaseのowner(書き込み、読み込み)のアクセス権にする
※ json形式で鍵を保存

メールアドレスと鍵を使ってstoreにアクセス

※ データはオブジェクト
※ keyは保存したjson形式の鍵の中のprivate_keyを使う
var key = "-----BEGIN PRIVATE KEY-----\n{省略}==\n-----END PRIVATE KEY-----\n",
FirestoreApp.createDocumentWithId("FirstCollection", "FirstDocument", data, email, key, projectId)

データ更新

FirestoreApp.updateDocument("FirstCollection/FirstDocument", data, email, key, projectId)

13

Go to list of users who liked

17
1

Go to list of comments

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
13

Go to list of users who liked

17