You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please make sure you have read the [Contributing](/grahamearley/FirestoreGoogleAppsScript/blob/main/.github/CONTRIBUTING.md) guidelines before submitting.
3
+
Please make sure you have read the [Contributing](CONTRIBUTING.md) guidelines before submitting.
Copy file name to clipboardExpand all lines: .github/README.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
# Firestore for Google Apps Scripts
2
2
3
-
[](/grahamearley/FirestoreGoogleAppsScript/releases/latest)
### A Google Apps Script library for accessing Google Cloud Firestore.
13
13
14
14
15
15
This library allows a user (or service account) to authenticate with Firestore and edit their Firestore database within a Google Apps Script.
16
16
17
-
Read how this project was started [here](http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html).
17
+
Read how this project was started [here](//grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html).
18
18
19
-
As of **v27**, this project has been updated to use the [GAS V8 runtime](https://developers.google.com/apps-script/guides/v8-runtime) with [Typescript](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html)! This introduces a number of [breaking changes](#breaking-changes). Scripts utilizing the old Rhino runtime must use **v26**.
19
+
As of **v27**, this project has been updated to use the [GAS V8 runtime](//developers.google.com/apps-script/guides/v8-runtime) with [Typescript](//www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html)! This introduces a number of [breaking changes](#breaking-changes). Scripts utilizing the old Rhino runtime must use **v26**.
20
20
21
21
## Installation
22
22
In the Google online script editor, select the `Resources` menu item and choose `Libraries...`. In the "Add a library" input box, enter **`1VUSl4b1r1eoNcRWotZM3e87ygkxvXltOgyDZhixqncz9lQ3MjfT1iKFw`** and click "Add." Choose the most recent version number.
@@ -25,15 +25,15 @@ In the Google online script editor, select the `Resources` menu item and choose
25
25
#### Creating a service account
26
26
The easiest way to use this library is to create a Google Service Account for your application and give it read/write access to your datastore. Giving a service account access to your datastore is like giving access to a user's account, but this account is strictly used by your script, not by a person.
27
27
28
-
If you don't already have a Firestore project you want to use, create one at the [Firebase admin console](https://console.firebase.google.com).
28
+
If you don't already have a Firestore project you want to use, create one at the [Firebase admin console](//console.firebase.google.com).
29
29
30
30
To make a service account,
31
-
1. Open the [Google Service Accounts page by clicking here](https://console.developers.google.com/projectselector/iam-admin/serviceaccounts).
31
+
1. Open the [Google Service Accounts page by clicking here](//console.developers.google.com/projectselector/iam-admin/serviceaccounts).
32
32
2. Select your Firestore project, and then click "Create Service Account."
33
33
3. For your service account's role, choose `Datastore > Cloud Datastore Owner`.
34
34
4. Check the "Furnish a new private key" box and select JSON as your key type.
35
35
5. When you press "Create," your browser will download a `.json` file with your private key (`private_key`), service account email (`client_email`), and project ID (`project_id`). Copy these values into your Google Apps Script — you'll need them to authenticate with Firestore.
36
-
6.**[Bonus]** It is considered best practice to make use of the [Properties Service](https://developers.google.com/apps-script/guides/properties) to store this sensitive information.
36
+
6.**[Bonus]** It is considered best practice to make use of the [Properties Service](//developers.google.com/apps-script/guides/properties) to store this sensitive information.
37
37
38
38
#### Configurating Firestore instance from your script
39
39
Now, with your service account client email address `email`, private key `key`, project ID `projectId`, we will authenticate with Firestore to get our `Firestore` object. To do this, get the `Firestore` object from the library:
Alternatively, using [Properties Service](https://developers.google.com/apps-script/guides/properties) <ins>once data is already stored</ins> in the service with **"client_email"**, **"private_key"**, and **"project_id"** property names:
54
+
Alternatively, using [Properties Service](//developers.google.com/apps-script/guides/properties) <ins>once data is already stored</ins> in the service with **"client_email"**, **"private_key"**, and **"project_id"** property names:
55
55
```javascript
56
56
constprops=PropertiesService.getUserProperties(); // Or .getScriptProperties() if stored in Script Properties
See other library methods and details [in the wiki](/grahamearley/FirestoreGoogleAppsScript/wiki/).
152
+
See other library methods and details [in the wiki](../../../wiki).
153
153
154
154
### Frequently Asked Questions
155
155
-**I'm getting the following error:**
156
156
> Missing ; before statement. at \[unknown function\](Auth:12)
157
157
158
-
This is because this library has been updated to utilize the new [V8 Engine](https://developers.google.com/apps-script/guides/v8-runtime), and classes are not supported in the Rhino Engine.
158
+
This is because this library has been updated to utilize the new [V8 Engine](//developers.google.com/apps-script/guides/v8-runtime), and classes are not supported in the Rhino Engine.
159
159
You can either:
160
-
1.[Migrate your script to use V8](https://developers.google.com/apps-script/guides/v8-runtime/migration), or
160
+
1.[Migrate your script to use V8](//developers.google.com/apps-script/guides/v8-runtime/migration), or
161
161
1. Use the last Rhino version of this library (**v26**).
162
162
163
163
@@ -171,10 +171,10 @@ See other library methods and details [in the wiki](/grahamearley/FirestoreGoogl
171
171
> Utilize `createDocument(path + '/' + documentId, fields)` instead to create a document with a specific ID.
172
172
173
173
## Contributions
174
-
Contributions are welcome — send a pull request! See [here](/grahamearley/FirestoreGoogleAppsScript/blob/main/.github/CONTRIBUTING.md) for more information on contributing.
174
+
Contributions are welcome — send a pull request! See [here](CONTRIBUTING.md) for more information on contributing.
175
175
176
-
After cloning this repository, you can push it to your own private copy of this Google Apps Script project to test it yourself. See [here](/google/clasp) for directions on using `clasp` to develop App Scripts locally.
176
+
After cloning this repository, you can push it to your own private copy of this Google Apps Script project to test it yourself. See [here](//github.com/google/clasp) for directions on using `clasp` to develop App Scripts locally.
177
177
Install all packages from `package.json` with a bare `npm install`.
178
178
179
179
180
-
If you want to view the source code directly on Google Apps Script, where you can make a copy for yourself to edit, click [here](https://script.google.com/d/1VUSl4b1r1eoNcRWotZM3e87ygkxvXltOgyDZhixqncz9lQ3MjfT1iKFw/edit).
180
+
If you want to view the source code directly on Google Apps Script, where you can make a copy for yourself to edit, click [here](//script.google.com/d/1VUSl4b1r1eoNcRWotZM3e87ygkxvXltOgyDZhixqncz9lQ3MjfT1iKFw/edit).
0 commit comments