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

Function getNotes

packages/core/src/db/note-queries.ts:12–40  ·  view source on GitHub ↗
(bookId: string)

Source from the content-addressed store, hash-verified

10} from "./db-core";
11
12export async function getNotes(bookId: string): Promise<Note[]> {
13 const database = await getDB();
14 const rows = await database.select<{
15 id: string;
16 book_id: string;
17 highlight_id: string | null;
18 cfi: string | null;
19 title: string;
20 content: string;
21 chapter_title: string | null;
22 tags: string;
23 created_at: number;
24 updated_at: number;
25 }>("SELECT * FROM notes WHERE book_id = ? ORDER BY created_at DESC", [bookId]);
26 return sortAnnotationsByPosition(
27 rows.map((r) => ({
28 id: r.id,
29 bookId: r.book_id,
30 highlightId: r.highlight_id || undefined,
31 cfi: r.cfi || undefined,
32 title: r.title,
33 content: r.content,
34 chapterTitle: r.chapter_title || undefined,
35 tags: parseJSON(r.tags, []),
36 createdAt: r.created_at,
37 updatedAt: r.updated_at,
38 })),
39 );
40}
41
42/** Get all notes across all books (for general chat without bookId) */
43export async function getAllNotes(limit = 50): Promise<Note[]> {

Callers 2

createGetAnnotationsToolFunction · 0.85

Calls 4

getDBFunction · 0.90
parseJSONFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected