( root: string, rel: string, rows: DbRow[] )
| 216 | |
| 217 | /** Persist rows to the CSV (schema/header come from the sidecar). */ |
| 218 | export async function writeDatabaseRows( |
| 219 | root: string, |
| 220 | rel: string, |
| 221 | rows: DbRow[] |
| 222 | ): Promise<DatabaseDoc> { |
| 223 | const sidecar = await readSidecar(root, rel) |
| 224 | if (!sidecar) throw new Error(`Database sidecar missing: ${rel}`) |
| 225 | await writeFileAtomic(databaseDataPath(root, rel), serializeRows(rows, sidecar.fields)) |
| 226 | return hydrate(rel, sidecar, rows.map((r) => ({ ...r }))) |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Persist schema + views to the sidecar AND rewrite the CSV under the new |
no test coverage detected