ditto/src/db.ts

19 lines
380 B
TypeScript
Raw Normal View History

import { createPentagon, z } from '@/deps.ts';
import { hexIdSchema } from '@/schema.ts';
2023-07-09 16:47:19 +00:00
const kv = await Deno.openKv();
2023-07-09 16:47:19 +00:00
const userSchema = z.object({
pubkey: hexIdSchema.describe('primary'),
2023-07-09 19:22:18 +00:00
username: z.string().regex(/^\w{1,30}$/).describe('unique'),
createdAt: z.date(),
2023-07-09 16:47:19 +00:00
});
const db = createPentagon(kv, {
users: {
schema: userSchema,
},
});
export { db };