Switch from Dongoose to Pentagon instead of the db
This commit is contained in:
parent
505b9db409
commit
c93aa5b314
23
src/db.ts
23
src/db.ts
|
@ -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({
|
const userSchema = z.object({
|
||||||
pubkey: z.string(),
|
pubkey: z.string().regex(/^[0-9a-f]{64}$/).describe('primary'),
|
||||||
username: z.string(),
|
username: z.string().regex(/^[\w_]+$/).describe('unique'),
|
||||||
}, {
|
createdAt: z.date(),
|
||||||
db,
|
|
||||||
name: 'users',
|
|
||||||
indexes: ['pubkey', 'username'],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export { db, Users };
|
const db = createPentagon(kv, {
|
||||||
|
users: {
|
||||||
|
schema: userSchema,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { db };
|
||||||
|
|
|
@ -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 sanitizeHtml } from 'npm:sanitize-html@^2.10.0';
|
||||||
export { default as ISO6391 } from 'npm:iso-639-1@2.1.15';
|
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 { Dongoose } from 'https://raw.githubusercontent.com/alexgleason/dongoose/68b7ad9dd7b6ec0615e246a9f1603123c1709793/mod.ts';
|
||||||
|
export { createPentagon } from 'https://deno.land/x/pentagon@v0.1.1/mod.ts';
|
||||||
|
|
Loading…
Reference in New Issue