FirestoreGoogleAppsScript icon indicating copy to clipboard operation
FirestoreGoogleAppsScript copied to clipboard

Apps script FirestoreApp when query 'collection1' where 'timestampField' == my_variable_Timestamp

Open ab2d3e8 opened this issue 3 years ago • 1 comments

Minimal code to reproduce the problem

const firestore = FirestoreApp.getFirestore(email, key, projectId);
var my_variable_Timestamp = Utilities.formatDate(new Date(), 'GMT -1', 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'')
const docsFS = firestore.query("collection1").Where("timestampField", "==",  my_variable_Timestamp  ).Execute();

Expected Behavior

There are no results.

Actual Results

I did not find a way to make the query, try converting the date to a number, for example

var my_variable_Timestamp = Number(new Date().getTime()).toFixed(0);

But without any result. I expect the library FirestoreApp, It does not contain a property Timestamp like

var my_variable_Timestamp =  firestore.Timestamp.fromDate( new Date() )

Is there a solution to this problem

Library Version:

last Version;

ab2d3e8 avatar Dec 05 '22 06:12 ab2d3e8

It seems unlikely that you would have any documents with a timestamp matching the exact moment when you initialised my_variable_timestamp. In any case, I like you, expected to have to format my own timestamp (I used new Date().toISOString()), however, the query worked property when I passed a Date object to the .Where() method directly.

michaelconan avatar Oct 13 '23 21:10 michaelconan