Google Cloud Firestore: notes and links






Notes from videos:

  • max 1 MB of data in a single document
  • max 20k of fields in a single document (including maps)
  • 1 write/second on a single document
  • can't retrieve a partial document
  • queries are shallow by default
  • billed by the number of reads and writes performed (2m read requests = $.12)
  • queries find documents in single (sub)collection
  • arrays are weird
  • you can't run 2 "array contains" queries on the same array
  • There's a limit to how many documents you can create per minute in a single collection if the documents have an always-increasing value (like a timestamp)
  • Very large collections don't do as well from a performance standpoint when you're offline.

Notes from docs:

  • Querying across multiple subcollections is not currently supported in Cloud Firestore. (collection group query). If you need to query data across collections, use root-level collections.*
  • Array: An array cannot contain another array value as one of its elements. Map: Represents an object embedded within a document. When indexed, you can query on subfields. If you exclude this value from indexing, then all subfields are also excluded from indexing.*
  • Cloud Firestore automatically maintains an index for each field in a document and each subfield in a map. Exempt from auto-indexing: large string/array/map fields, timestamps.*
  • You also get full query capabilities on subcollections (individual, not multiple).*

Emulator local install

1) Install nvm/npm

curl -o- | bash

2) Update node.js

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

3) Install Java JDK (JRE is not enough)

4) Install the Firebase CLI

npm install -g firebase-tools
firebase login

5) Install the emulator

firebase setup:emulators:firestore

6) Install @firebase/testing module

npm install @firebase/testing

7) Start the emulator

firebase serve --only firestore