( tableId: string, rowId: string, workspaceId: string )
| 1067 | * @returns Row or null if not found |
| 1068 | */ |
| 1069 | export async function getRowById( |
| 1070 | tableId: string, |
| 1071 | rowId: string, |
| 1072 | workspaceId: string |
| 1073 | ): Promise<TableRow | null> { |
| 1074 | const results = await db |
| 1075 | .select() |
| 1076 | .from(userTableRows) |
| 1077 | .where( |
| 1078 | and( |
| 1079 | eq(userTableRows.id, rowId), |
| 1080 | eq(userTableRows.tableId, tableId), |
| 1081 | eq(userTableRows.workspaceId, workspaceId) |
| 1082 | ) |
| 1083 | ) |
| 1084 | .limit(1) |
| 1085 | |
| 1086 | if (results.length === 0) return null |
| 1087 | |
| 1088 | const row = results[0] |
| 1089 | const executions = await loadExecutionsForRow(db, row.id) |
| 1090 | return { |
| 1091 | id: row.id, |
| 1092 | data: row.data as RowData, |
| 1093 | executions, |
| 1094 | position: row.position, |
| 1095 | orderKey: row.orderKey ?? undefined, |
| 1096 | createdAt: row.createdAt, |
| 1097 | updatedAt: row.updatedAt, |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | /** Internal: thrown inside `db.transaction` to roll back when the executions |
| 1102 | * guard rejects a write. The outer `.catch` translates it into a `null` return. */ |
no outgoing calls
no test coverage detected