MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / noteToDocType

Function noteToDocType

app/src/sqlite/note.ts:39–68  ·  view source on GitHub ↗
(note: Note)

Source from the content-addressed store, hash-verified

37import initSql from 'shared/sql.json'
38
39function noteToDocType(note: Note) {
40 const now = C.getDate().getTime()
41 return [
42 {
43 id: toLDbId(note.id),
44 templateId: toLDbId(note.templateId),
45 created: now,
46 edited: now,
47 ankiNoteId: note.ankiNoteId,
48 },
49 Array.from(note.tags).map((tag) => ({ tag, noteId: toLDbId(note.id) })),
50 objEntries(note.fieldValues).map(([field, value]) => ({
51 noteId: note.id,
52 field,
53 value,
54 })),
55 objEntries(note.remotes).map(([nook, remote]) => ({
56 note,
57 localId: toLDbId(note.id),
58 nook,
59 remoteId: toLDbId(remote?.remoteNoteId),
60 uploadDate: remote?.uploadDate.getTime(),
61 })),
62 ] satisfies [
63 InsertObject<DB, 'noteBase'>,
64 Array<InsertObject<DB, 'noteTag'>>,
65 Array<InsertObject<DB, 'noteFieldValue'>>,
66 Array<InsertObject<DB, 'remoteNote'> & { note: Note }>,
67 ]
68}
69
70function domainToCreateRemote(
71 { id, tags, fieldValues }: Note,

Callers

nothing calls this directly

Calls 1

toLDbIdFunction · 0.90

Tested by

no test coverage detected