36 lines
852 B
TypeScript
36 lines
852 B
TypeScript
import {
|
|
EntryFor,
|
|
Schema,
|
|
Store,
|
|
} from "https://git.barnulf.net/mb/debilus/raw/commit/fc701bec680dd73be29c72164f47ee87fac540c7/mod.ts";
|
|
import { project_root } from "./utils.ts";
|
|
|
|
export const db = await Store.open(
|
|
new Schema({
|
|
user: {
|
|
username: "string",
|
|
password: "string",
|
|
upvoted_posts: ["many", "post"],
|
|
upvoted_comments: ["many", "comment"],
|
|
posts: ["many", "post"],
|
|
},
|
|
post: {
|
|
title: "string",
|
|
content: "string",
|
|
upvotes: "number",
|
|
author: ["one", "user"],
|
|
comments: ["many", "comment"],
|
|
},
|
|
comment: {
|
|
content: "string",
|
|
upvotes: "number",
|
|
author: ["one", "user"],
|
|
post: ["one", "post"],
|
|
},
|
|
}),
|
|
`${project_root()}/local/db.kv`,
|
|
);
|
|
|
|
export type User = EntryFor<typeof db, "user">;
|
|
export type Post = EntryFor<typeof db, "post">;
|
|
export type Comment = EntryFor<typeof db, "comment">;
|