Skip to content

Firestore Method Documentation

Graham Earley edited this page Sep 21, 2018 · 11 revisions

To get an instance of the Firestore object for your project from this library, call

var firestore = FirestoreApp.getFirestore(email, key, projectId);

This page documents the methods that belong to the Firestore object.

Library version: 22


Table of Contents

getFirestore

Get an object that acts as an authenticated interface with a Firestore project.

Parameters

  • email string the user email address (for authentication)
  • key string the user private key (for authentication)
  • projectId string the Firestore project ID

Returns object an authenticated interface with a Firestore project

Firestore

An object that acts as an authenticated interface with a Firestore project.

Parameters

  • email string the user email address (for authentication)
  • key string the user private key (for authentication)
  • projectId string the Firestore project ID

Returns object an authenticated interface with a Firestore project

getDocument

Get a document.

Parameters

  • path string the path to the document

Returns object the document object

getDocuments

Get a list of all documents in a collection.

Parameters

  • path string the path to the collection

Returns object an array of the documents in the collection

getDocumentIds

Get a list of all IDs of the documents in a path

Parameters

  • path string the path to the collection

Returns object an array of IDs of the documents in the collection

createDocument

Create a document with the given fields and an auto-generated ID.

Parameters

  • path string the path where the document will be written
  • fields object the document's fields

Returns object the Document object written to Firestore

updateDocument

Update/patch a document at the given path with new fields.

Parameters

  • path string the path of the document to update. If document name not provided, a random ID will be generated.
  • fields object the document's new fields
  • mask boolean if true, the update will use a mask

Returns object the Document object written to Firestore

query

Run a query against the Firestore Database and return an all the documents that match the query. Must call .execute() to send the request.

Parameters

Returns object the JSON response from the GET request

deleteDocument

Delete the Firestore document at the given path. Note: this deletes ONLY this document, and not any subcollections.

Parameters

  • path string the path to the document to delete

Returns object the JSON response from the DELETE request