database basically working

This commit is contained in:
metacryst
2026-01-11 03:47:36 -06:00
parent 463dd183f5
commit 13cdff7a5f
19 changed files with 389 additions and 210 deletions

29
server/db/model/title.js Normal file
View File

@@ -0,0 +1,29 @@
import { z } from 'zod';
export default class Title {
prefix = `TITLE`
indices = null
constructor(indices) {
this.indices = indices
}
schema = z.object({
id: z.number(),
name: z.string()
})
save(newTitle) {
let id = `HY-${this.entries.length+1}`
if(this.validate(id, newTitle)) {
try {
global.db.add(id, newTitle)
} catch(e) {
console.error(e)
throw e
}
} else {
throw new global.ServerError(400, "Invalid Member Data!");
}
}
}