Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ab2d3e8 opened this issue Dec 5, 2022 · 1 comment
Labels

Comments

@ab2d3e8
Copy link

ab2d3e8 commented Dec 5, 2022

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 ab2d3e8 added the bug label Dec 5, 2022
@michaelconan
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants