Sorting
Use orderBy and order to sort your results by a specific field.
- Ascending: Use
order: 'asc'(default). - Descending: Use
order: 'desc'.
Ascending order
This example sorts users by their first name in ascending order (A-Z).
- Manta data table
- PostgreSQL
TypeScript
const users = await manta.fetchAllRecords({
table: "users",
fields: ["user_id", "first_name", "last_name"],
orderBy: "first_name",
order: "asc", // ascending order
page: 1,
list: 10,
})
TypeScript
const users = await manta.fetchAllRecords({
db: 'analytics_pg',
table: "users",
fields: ["user_id", "first_name", "last_name"],
orderBy: "first_name",
order: "asc", // ascending order
page: 1,
list: 10,
});
Descending Order
This example sorts orders by their amount in descending order (highest to lowest).
- Manta data table
- PostgreSQL
TypeScript
const users = await manta.fetchAllRecords({
table: "orders",
fields: ["order_id", "amount"],
orderBy: "amount",
order: "desc", // descending order
page: 1,
list: 10,
})
TypeScript
const users = await manta.fetchAllRecords({
db: 'analytics_pg',
table: "orders",
fields: ["order_id", "amount"],
orderBy: "amount",
order: "desc", // descending order
page: 1,
list: 10,
});