prune: remove content prop

This commit is contained in:
Julien Calixte
2026-02-09 22:12:30 +01:00
parent 069951dff2
commit e46714230f
4 changed files with 11 additions and 18 deletions

View File

@@ -37,7 +37,7 @@ deno fmt
- **Runtime**: Deno (not Bun, despite the README). Uses `deno.json` for task definitions and import maps. - **Runtime**: Deno (not Bun, despite the README). Uses `deno.json` for task definitions and import maps.
- **Database**: SQLite via `https://deno.land/x/sqlite/mod.ts`. DB path is configurable via `SQLITE_PATH` env var, defaults to `notes.db`. - **Database**: SQLite via `https://deno.land/x/sqlite/mod.ts`. DB path is configurable via `SQLITE_PATH` env var, defaults to `notes.db`.
- **Note schema**: Defined as an AT Protocol lexicon in `lexicons/space/litenote/note.json`. Notes have `title`, `content` (markdown), optional `images` (blob refs), `publishedAt`, and `createdAt`. Primary key is `(did, rkey)`. - **Note schema**: Defined as an AT Protocol lexicon in `lexicons/space/litenote/note.json`. Notes have `title`, optional `images` (blob refs), `publishedAt`, and `createdAt`. Primary key is `(did, rkey)`.
- **API endpoints**: - **API endpoints**:
- `GET /notes?cursor=&limit=` — paginated notes (all users) - `GET /notes?cursor=&limit=` — paginated notes (all users)
- `GET /:did/notes?cursor=&limit=` — paginated notes for a specific DID - `GET /:did/notes?cursor=&limit=` — paginated notes for a specific DID

View File

@@ -5,20 +5,19 @@ export const db = new DB(Deno.env.get("SQLITE_PATH") ?? "notes.db");
export const getNotes = (cursor?: string, limit = 20) => { export const getNotes = (cursor?: string, limit = 20) => {
const rows = cursor const rows = cursor
? db.query<[string, string, string, string, string, string]>( ? db.query<[string, string, string, string, string]>(
"SELECT did, rkey, title, content, publishedAt, createdAt FROM note WHERE rkey < ? ORDER BY rkey DESC LIMIT ?", "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE rkey < ? ORDER BY rkey DESC LIMIT ?",
[cursor, limit], [cursor, limit],
) )
: db.query<[string, string, string, string, string, string]>( : db.query<[string, string, string, string, string]>(
"SELECT did, rkey, title, content, publishedAt, createdAt FROM note ORDER BY rkey DESC LIMIT ?", "SELECT did, rkey, title, publishedAt, createdAt FROM note ORDER BY rkey DESC LIMIT ?",
[limit], [limit],
); );
const notes = rows.map(([did, rkey, title, content, publishedAt, createdAt]) => ({ const notes = rows.map(([did, rkey, title, publishedAt, createdAt]) => ({
did, did,
rkey, rkey,
title, title,
content,
publishedAt, publishedAt,
createdAt, createdAt,
})); }));
@@ -31,20 +30,19 @@ export const getNotes = (cursor?: string, limit = 20) => {
export const getNotesByDid = (did: string, cursor?: string, limit = 20) => { export const getNotesByDid = (did: string, cursor?: string, limit = 20) => {
const rows = cursor const rows = cursor
? db.query<[string, string, string, string, string, string]>( ? db.query<[string, string, string, string, string]>(
"SELECT did, rkey, title, content, publishedAt, createdAt FROM note WHERE did = ? AND rkey < ? ORDER BY rkey DESC LIMIT ?", "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE did = ? AND rkey < ? ORDER BY rkey DESC LIMIT ?",
[did, cursor, limit], [did, cursor, limit],
) )
: db.query<[string, string, string, string, string, string]>( : db.query<[string, string, string, string, string]>(
"SELECT did, rkey, title, content, publishedAt, createdAt FROM note WHERE did = ? ORDER BY rkey DESC LIMIT ?", "SELECT did, rkey, title, publishedAt, createdAt FROM note WHERE did = ? ORDER BY rkey DESC LIMIT ?",
[did, limit], [did, limit],
); );
const notes = rows.map(([did, rkey, title, content, publishedAt, createdAt]) => ({ const notes = rows.map(([did, rkey, title, publishedAt, createdAt]) => ({
did, did,
rkey, rkey,
title, title,
content,
publishedAt, publishedAt,
createdAt, createdAt,
})); }));
@@ -60,7 +58,6 @@ export const upsertNote = (note: Note) => {
` `
INSERT INTO note ( INSERT INTO note (
title, title,
content,
publishedAt, publishedAt,
createdAt, createdAt,
did, did,
@@ -70,12 +67,10 @@ export const upsertNote = (note: Note) => {
ON CONFLICT(did, rkey) ON CONFLICT(did, rkey)
DO UPDATE SET DO UPDATE SET
title = excluded.title, title = excluded.title,
content = excluded.content,
publishedAt = excluded.publishedAt publishedAt = excluded.publishedAt
`, `,
[ [
note.title, note.title,
note.content,
new Date(note.publishedAt).toISOString(), // publishedAt new Date(note.publishedAt).toISOString(), // publishedAt
new Date(note.createdAt).toISOString(), // createdAt new Date(note.createdAt).toISOString(), // createdAt
note.did, note.did,

View File

@@ -2,7 +2,6 @@ export type Note = {
did: string; did: string;
rkey: string; rkey: string;
title: string; title: string;
content: string;
publishedAt: Date; publishedAt: Date;
createdAt: Date; createdAt: Date;
}; };

View File

@@ -3,7 +3,6 @@ import { db } from "../data/db.ts";
db.execute(` db.execute(`
CREATE TABLE IF NOT EXISTS note ( CREATE TABLE IF NOT EXISTS note (
title TEXT NOT NULL, title TEXT NOT NULL,
content TEXT NOT NULL,
publishedAt DATETIME, publishedAt DATETIME,
createdAt DATETIME NOT NULL, createdAt DATETIME NOT NULL,
did TEXT NOT NULL, did TEXT NOT NULL,