How to retrieve whole nested data form multiple document from firebase in flutter

Viewed 23

How can I retrieve the all the data form each uid with their nested field and order them in according to order sent time.

Here is the structure of database

image

1 Answers

Since the order sent at field is in the Delivery array field, there can be multiple values for each document. In order to sort on a field, there must be a single value for each document.

The easiest way to allow the use-case is to introduce a new top-level field in the document, for example most recent order sent at, that you then update whenever you add a order sent at value to the Delivery array.

Once this field exists, you can order on it in your queries.

Related