A Google Apps Script library for accessing Google Cloud Firestore.
This release comes after a long break.
var db = getFirestore(email, key, project);
var results10_15 = db.query(path).range(10, 15).execute();
Which is equivalent to:
var db = getFirestore(email, key, project);
var results10_15 = db.query(path).offset(10).limit(5).execute();
createTime
and updateTime
document properties are JS Date objects and not Timestamp Strings.Now the update function includes an extra boolean parameter, mask
. When true, the update will apply as a mask. So if your document looks like this:
{ number: 1, text: "Hello" }
and you call update with mask = true
with this object as your mask:
{ number: 2 }
then the number
field will be updated, but the text field will not. The resulting document will be
{ number: 2, text: "Hello" }
Thanks to @webstermath for this feature!
This version adds a new operator for querying. You can now query for documents with an array field that contains some value. For example, say you have a collection "My Collection" of documents that each have an array field called numbers
. To find all documents with 42 in their numbers
array, you can now query like this:
firestore.query("My Collection").where("numbers", "contains", 42).execute();
Thanks to @joao-azevedo-hydradev for this addition!
This release is a hotfix for a bug in v18, where our isNaN
check said that any non-number type was NaN
. Now the check only checks for NaN
if the value is of type number.
This version merges in another nice PR from @LaughDonor (#33), which the query method where(field, "==", null)
to be equivalent to the query method where(field, "null")
(similarly for undefined
, NaN
).
Before this version, an empty array in a document would cause an error in the library. No more! Thanks for finding the issue @adyscorpius, and thanks for the fix @LaughDonor.
Versions 8 through 14 are all essentially the same — I was just getting used to using the clasp
library and so I accidentally deployed a few times with the wrong release description :)
This version adds support for querying within collection! It also adds support for all data types you can store in Firestore (including timestamps, geopoints, and references to other documents).
See documentation here.
Huge thanks to @LaughDonor for the great work in this release.