Reputation:
I have a database like this.
How can I order by the timestamp field in the array?
.orderBy("received[0].timestamp", "desc")
Upvotes: 4
Views: 2168
Reputation: 3149
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.
Upvotes: 4