Abdelhadi Abdo
Abdelhadi Abdo

Reputation: 412

Firestore startAt with timestamp field not work

I try to paginate chronologically by created_at field (type of this field is timestamp), but the problem the following query with start_at return null, despite I have data after the given date (created_date).

  snapshot = await FirebaseHelper.FirebaseContext.firestore()
      .collection("Announcements")
      .orderBy("created_at", "desc")
      .startAt(1617235200000) // --> not work
      .limit(3)
     // .where("created_at", ">", 1617235200000) --> this not work also
      .get();

With startAt result is NULL !

Without startAt I got results

enter image description here

enter image description here

From docs: https://firebase.google.com/docs/firestore/query-data/query-cursors enter image description here

If I use other field for pagination (for example the ID) it works ! This reproduce just with timestamp field

Upvotes: 1

Views: 1135

Answers (2)

Sudhakar
Sudhakar

Reputation: 28

Use:

.start_at({"timestamp":datetime.datetime.now()})

Upvotes: 0

Kundan
Kundan

Reputation: 1962

You should add an actual timestamp to your startAt method like

startAt('1617235200000')

Upvotes: 1

Related Questions