MCPcopy
hub / github.com/codedogQBY/ReadAny / updateNote

Function updateNote

packages/core/src/db/note-queries.ts:94–125  ·  view source on GitHub ↗
(id: string, updates: Partial<Note>)

Source from the content-addressed store, hash-verified

92}
93
94export async function updateNote(id: string, updates: Partial<Note>): Promise<void> {
95 const database = await getDB();
96 const sets: string[] = [];
97 const values: unknown[] = [];
98
99 if (updates.title !== undefined) {
100 sets.push("title = ?");
101 values.push(updates.title);
102 }
103 if (updates.content !== undefined) {
104 sets.push("content = ?");
105 values.push(updates.content);
106 }
107 if (updates.tags !== undefined) {
108 sets.push("tags = ?");
109 values.push(JSON.stringify(updates.tags));
110 }
111 // Add sync tracking
112 const deviceId = await getDeviceId();
113 const syncVersion = await nextSyncVersion(database, "notes");
114 const updatedAt = await nextUpdatedAt(database, "notes", id);
115 sets.push("updated_at = ?");
116 values.push(updatedAt);
117 sets.push("sync_version = ?");
118 values.push(syncVersion);
119 sets.push("last_modified_by = ?");
120 values.push(deviceId);
121
122 if (sets.length === 0) return;
123 values.push(id);
124 await database.execute(`UPDATE notes SET ${sets.join(", ")} WHERE id = ?`, values);
125}
126
127export async function deleteNote(id: string): Promise<void> {
128 const database = await getDB();

Callers 1

Calls 6

getDBFunction · 0.90
getDeviceIdFunction · 0.90
nextSyncVersionFunction · 0.90
nextUpdatedAtFunction · 0.90
pushMethod · 0.80
executeMethod · 0.65

Tested by

no test coverage detected