MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / writeDatabaseRows

Function writeDatabaseRows

apps/desktop/src/main/databases.ts:218–227  ·  view source on GitHub ↗
(
  root: string,
  rel: string,
  rows: DbRow[]
)

Source from the content-addressed store, hash-verified

216
217/** Persist rows to the CSV (schema/header come from the sidecar). */
218export 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

Callers 2

registerIpcFunction · 0.90
databases.test.tsFile · 0.90

Calls 5

writeFileAtomicFunction · 0.90
databaseDataPathFunction · 0.90
serializeRowsFunction · 0.90
readSidecarFunction · 0.85
hydrateFunction · 0.70

Tested by

no test coverage detected