Switch from Dongoose to Pentagon instead of the db

This commit is contained in:
Alex Gleason 2023-07-09 12:27:10 -05:00
parent 505b9db409
commit c93aa5b314
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 14 additions and 10 deletions

View File

@ -1,14 +1,17 @@
import { Dongoose, z } from '@/deps.ts';
import { createPentagon, z } from '@/deps.ts';
const db = await Deno.openKv();
const kv = await Deno.openKv();
const Users = Dongoose({
pubkey: z.string(),
username: z.string(),
}, {
db,
name: 'users',
indexes: ['pubkey', 'username'],
const userSchema = z.object({
pubkey: z.string().regex(/^[0-9a-f]{64}$/).describe('primary'),
username: z.string().regex(/^[\w_]+$/).describe('unique'),
createdAt: z.date(),
});
export { db, Users };
const db = createPentagon(kv, {
users: {
schema: userSchema,
},
});
export { db };

View File

@ -38,3 +38,4 @@ export { default as uuid62 } from 'npm:uuid62@^1.0.2';
export { default as sanitizeHtml } from 'npm:sanitize-html@^2.10.0';
export { default as ISO6391 } from 'npm:iso-639-1@2.1.15';
export { Dongoose } from 'https://raw.githubusercontent.com/alexgleason/dongoose/68b7ad9dd7b6ec0615e246a9f1603123c1709793/mod.ts';
export { createPentagon } from 'https://deno.land/x/pentagon@v0.1.1/mod.ts';