prune: remove content prop
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -2,7 +2,6 @@ export type Note = {
|
||||
did: string;
|
||||
rkey: string;
|
||||
title: string;
|
||||
content: string;
|
||||
publishedAt: Date;
|
||||
createdAt: Date;
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user