Firebase Firestory query where stored timestamp is in the past

前端 未结 1 1167
灰色年华
灰色年华 2021-01-26 06:53

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 retur

相关标签:
1条回答
  • 2021-01-26 07:44

    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() 
    
    0 讨论(0)
提交回复
热议问题