How to sort a query?

Hello, the airtable documentation shows that to sort a query using selectRecordsAsync you should do it as follows:

let queryResult = await table.selectRecordsAsync({
    sorts: [
       // sort by "Description" in ascending order
       {field: "Description"},
       // then by "Priority" in descending order.
       {field: "Priority", direction: "desc"},
    ]
});

but this is apparently deprecated. How can I do it with the current codebase?

Can you please say why you think this is deprecated?

I think I solved my problem. Correct me if I’m wrong, but before, when I used

let query = await table.selectRecordsAsync({sorts: [{field: "some column"}]})

I had a message where it told me that behavior was deprecated, but I think it was referring to the fact that I hadn’t specified any fields.

If the documentation had shown an example using both the fields and sorts argument together I think I would have spared myself the confusion.

1 Like