How to sort a query?

Topic Labels: Scripting extentions
1490 2
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

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?

2 Replies 2

Can you please say why you think this is deprecated?

6 - Interface Innovator
6 - Interface Innovator

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.