Firestore query by date range

前端 未结 9 926
悲&欢浪女
悲&欢浪女 2020-12-02 12:11

I need the help to query long collection with date range. See the below example document. I wanna query startTime field using date range.

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 12:40

    You could store the datetime object as Unix time (seconds since 1 January 1970). Then you can simple use the where select like this:

    collectionRef.where("startTime", ">=", "1506816000").where("startTime", "<=", "1507593600")

    Btw - to convert from datetime to Unix time in your app, you can use the excellent library moment (if you are building something with js or node).

提交回复
热议问题