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

Function createRecordPage

apps/desktop/src/main/databases.ts:304–318  ·  view source on GitHub ↗
(
  root: string,
  csvPath: string,
  title: string,
  body: string
)

Source from the content-addressed store, hash-verified

302 * nest under the database in the sidebar.
303 */
304export async function createRecordPage(
305 root: string,
306 csvPath: string,
307 title: string,
308 body: string
309): Promise<string> {
310 const formDir = formDirFromCsvPath(toPosix(csvPath))
311 if (!formDir) throw new Error(`Not a database folder: ${csvPath}`)
312 const dirAbs = databaseDataPath(root, formDir) // resolveSafe + posix
313 await fs.mkdir(dirAbs, { recursive: true })
314 const finalTitle = await uniqueTitle(dirAbs, sanitizeNoteTitle(title))
315 const noteRel = `${formDir}/${finalTitle}.md`
316 await fs.writeFile(databaseDataPath(root, noteRel), body, 'utf8')
317 return noteRel
318}
319
320/**
321 * Permanently delete a database: remove its entire `<Name>.base` folder

Callers 3

registerIpcFunction · 0.90
databases.test.tsFile · 0.90

Calls 5

formDirFromCsvPathFunction · 0.90
databaseDataPathFunction · 0.90
uniqueTitleFunction · 0.90
sanitizeNoteTitleFunction · 0.90
toPosixFunction · 0.70

Tested by

no test coverage detected