sg.sysel
sg.sysel

Reputation: 163

Sort gcloud firestore operations by start time descending

I am trying to get the status of the latest firestore export via Gcloud CLI.

However, if I execute

gcloud firestore operations list --limit=5 --sort-by="~metadata.startTime"

the results are not sorted by the start time in descending order. If I add --format="value(metadata.startTime)", I get the correct output

2023-01-17T00:05:13.818312Z
2023-01-17T15:30:19.362908Z
2023-01-18T08:11:18.433556Z
2023-01-19T00:05:01.440255Z
2023-01-20T00:05:04.135387Z

How can I achieve the results being sorted by the startTime in descending order?

Upvotes: 1

Views: 119

Answers (1)

Rohit Kharche
Rohit Kharche

Reputation: 2919

At first glance it seems you are using the --sort-by flag incorrectly it should be used with [ ] as per the documentation.

The final command would be:

gcloud firestore operations list --limit=5 --sort-by=[~metadata.startTime] --format="value(metadata.startTime)"

This will list the last 5 operations and sort them by start time in descending order.

But when I tried with above command also it seems the issue is still there.I have raised this issue at with google.

Upvotes: 2

Related Questions