Skip to main content
Best answer

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

  • November 7, 2021
  • 2 replies
  • 633 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?

Best answer by SamB

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! :)

View original
Did this topic help you find an answer to your question?
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

SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 7592 replies
  • Answer
  • November 10, 2021

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! :)


  • New
  • 1 reply
  • January 13, 2022

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