Help us understand the problem. What is going on with this article?

firestoreにgoogle app script

More than 1 year has passed since last update.

課題

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

作戦

  • spread sheet => gas => firestore

APEENDIX

https://github.com/grahamearley/FirestoreGoogleAppsScript

やったこと

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)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away