grahamearley / FirestoreGoogleAppsScript

A Google Apps Script library for accessing Google Cloud Firestore.
http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html
MIT License
648 stars 109 forks source link

How to query by timestamp #108

Closed danieleorlando closed 4 years ago

danieleorlando commented 4 years ago

How to query a collection by a timestamp field?

I tried so many combinations that I can't figure it out

LaughDonor commented 4 years ago

Is it an actual field, or the metadata? We cannot query on the meta data, whereas we can query the field values.

danieleorlando commented 4 years ago

It's a field

LaughDonor commented 4 years ago

Can you provide an example query you utilized to get this information as well as the Library version number?

danieleorlando commented 4 years ago

I'm using version 26

const allDocuments = firestore.query(collection).where(field, ">=", date).execute();

I tried date like date = new Date() date = new Date("2020-01-01")

Probably I don't know how to format date

where(field, "==", name).execute(); this works perfectly

danieleorlando commented 4 years ago

Updated to v33. Now query by timestamp works perfectly