Type fixes.

This commit is contained in:
mike12345567 2023-10-19 16:56:45 +01:00
parent 470735cc97
commit d1b551c6aa
3 changed files with 3 additions and 5 deletions

View File

@ -117,7 +117,7 @@ export function enrichViewSchemas(table: Table): TableResponse {
views: Object.values(table.views ?? [])
.map(v => sdk.views.enrichSchema(v, table.schema))
.reduce((p, v) => {
p[v.name] = v
p[v.name!] = v
return p
}, {} as TableViewsResponse),
}

View File

@ -59,11 +59,10 @@ export async function update(tableId: string, view: ViewV2): Promise<ViewV2> {
const existingView = Object.values(views).find(
v => isV2(v) && v.id === view.id
)
if (!existingView) {
if (!existingView || !existingView.name) {
throw new HTTPError(`View ${view.id} not found in table ${tableId}`, 404)
}
console.log("set to", view)
delete views[existingView.name]
views[view.name] = view
await db.put(ds)

View File

@ -51,11 +51,10 @@ export async function update(tableId: string, view: ViewV2): Promise<ViewV2> {
const existingView = Object.values(table.views).find(
v => isV2(v) && v.id === view.id
)
if (!existingView) {
if (!existingView || !existingView.name) {
throw new HTTPError(`View ${view.id} not found in table ${tableId}`, 404)
}
console.log("set to", view)
delete table.views[existingView.name]
table.views[view.name] = view
await db.put(table)