Firebase Firestory Query Where Stored Timestamp Is In The Past
I need to delete all Documents which have a timestamp (stored in a field) prior to today. The timestamp is created in the Firestore GUI. The following query doesnt return any docs.
Solution 1:
Whenever passing a date to Firestore, you should pass in an actual Date
object. Date.now()
returns a timestamp, which is just a number and not a Date
object itself. To get the actual Date
for the same value, use new Date()
. So:
collectionRef
.where('timestampFieldName', '<', new Date())
.get()
Post a Comment for "Firebase Firestory Query Where Stored Timestamp Is In The Past"