How to reorder Firestore data variable

I just found out that it’s not possible to order a Firestore collection query after using an = operator as a filter condition :frowning:

* You cannot order your query by any field included in an equality ( =) orin clause.

Instead, I’m now wondering if it’s possible to order the data after it’s been received from Firestore, and then save the reordered data as a new data variable. Has anyone been able to reorder a Firestore data variable in this way?

In my specific example, my Firestore query is looking for entried that match a specific string. I then want to have this data ordered by a timestamp (which is another field in the data).

Ok I got it. Created a new data variable, and used SORT_BY_KEY on the Firestore Data variable to order the data as I needed it.

Hope this might be useful for anyone else having issues with filtering / ordering data from Firebase!

@Kieran_Doyle I’m trying to do the same thing. May I know where you apply the SORT_BY_KEY function?

TIA.

Most probably it is used after the “Get record collection” flow inside the “Set data variable” flow function.

When it asks for the record. You can use the formula binding here and do the following:

In this case I had a record collection in which the data records have a field “name” and I wanted to sort by “name” in ascending order.
Hence the formula was:

ORDER(outputs["Get record collection"].records, item.name, "asc")
1 Like

@Mihaly_Toth It works! Thanks :smiley:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.