4

I have a database like this.

enter image description here

How can I order by the timestamp field in the array?

.orderBy("received[0].timestamp", "desc")

1 Answer 1

4

You cannot directly. But what you can do is create a new field on your document called firstTimestamp or something similar, and then replicate the timestamp from the first element of the array into that field. You can do that in a Cloud Function or in your frontend/backend code. That way you can sort or filter by that field.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much.
I didn't understand the answer, can you elaborate with an example?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.