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

@@ -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,