Fixing an issue with sorting in SQS.

This commit is contained in:
mike12345567 2024-06-18 13:53:51 +01:00
parent 5c45370722
commit 0caff1a404
1 changed files with 6 additions and 0 deletions

View File

@ -95,6 +95,8 @@ function buildTableMap(tables: Table[]) {
// update the table name, should never query by name for SQLite // update the table name, should never query by name for SQLite
table.originalName = table.name table.originalName = table.name
table.name = table._id! table.name = table._id!
// need a primary for sorting, lookups etc
table.primary = ["_id"]
tableMap[table._id!] = table tableMap[table._id!] = table
} }
return tableMap return tableMap
@ -153,6 +155,10 @@ export async function search(
const allTables = await sdk.tables.getAllInternalTables() const allTables = await sdk.tables.getAllInternalTables()
const allTablesMap = buildTableMap(allTables) const allTablesMap = buildTableMap(allTables)
// make sure we have the mapped/latest table
if (table?._id) {
table = allTablesMap[table?._id]
}
if (!table) { if (!table) {
throw new Error("Unable to find table") throw new Error("Unable to find table")
} }