Best answer

How to sort Firebase by calling setWithPriority and using Firebase.ServerValue.TIMESTAMP?

  • 7 November 2021
  • 2 replies
  • 604 views

Hello

I have an issue with my firebase integration (firestore). Firebase is supposed to trigger something when a new record is created in firebase.

Note that my firestore document is named by me and I am not using the randomly generated name by firebase.

Here is what I use (creationDate is an integer and it is the time in seconds the document was created) 

    "orderBy": [{
"field": {
"fieldPath": "creationDate"
},
"direction": "DESCENDING"
}]

I have found this article but I am not sure how to do that. 

My Firebase Zap isn't triggering when I add new records

New records need to appear at the top of your data so the Zap can see the most recent records. If you aren’t using push IDs, your records need to be ordered lexicographically or by priority so new records appear at the top.

A simple way to accomplish this is by calling setWithPriority and using Firebase.ServerValue.TIMESTAMP to order by timestamp.

 

Can anyone suggest which query should I add in Zapier?

icon

Best answer by SamB 10 November 2021, 12:11

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +11

Welcome to the Community, @m4trix

I’d have thought that the first query you referenced should be the one you want as it sounds like you’re not ordering your documents lexicographically or by priority. 

Is the creationDate field under a subcategory by any chance?

If so, you should be able to get it working by adding the name of the subcategory followed by a dot to the field path. For example:

"orderBy": [{
"field": {
"fieldPath": "subcategoryname.creationDate"
},
"direction": "DESCENDING"
}]

Hope that helps! :)

It seems that `setWithPriority` only works if you are using Firestore Realtime Database. It seems this remains unsolved for Firestore