AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
import type { DatabaseAdapter, PreparedStatementAdapter } from "./storage-contract";
export const upsertMemoSearchDocumentStatement = (
database: DatabaseAdapter,
memoId: string,
title: string | null,
contentText: string,
tags: string,
): PreparedStatementAdapter => database.prepare(
`INSERT INTO memo_search_documents (memo_id, title, content_text, tags)
VALUES (?, ?, ?, ?)
ON CONFLICT(memo_id) DO UPDATE SET
title = excluded.title,
content_text = excluded.content_text,
tags = excluded.tags`,
).bind(memoId, title, contentText, tags);
export const deleteMemoSearchDocumentsStatement = (
database: DatabaseAdapter,
memoIds: string[],
): PreparedStatementAdapter => {
const placeholders = memoIds.map(() => "?").join(", ");
return database.prepare(
`DELETE FROM memo_search_documents WHERE memo_id IN (${placeholders})`,
).bind(...memoIds);
};