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

View File

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

View File

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