Javascript

This commit is contained in:
metacryst
2025-11-08 07:03:30 -06:00
parent e17efce338
commit 6f9ed49b2e
23 changed files with 445 additions and 891 deletions

31
server/db/db.js Normal file
View File

@@ -0,0 +1,31 @@
import QuillDB from "../_/quilldb.js"
export default class Database extends QuillDB {
get = {
user: (id) => {
return this.nodes[id]
},
userByEmail: (email) => {
for (const id of this.labels["User"]) {
const user = this.get.user(id);
if (user.email === email) {
return { id, ...user }
}
}
return null;
},
}
generateUserID() {
let id = this.labels["User"].length + 1;
while (this.get.user(`user-${id}`)) {
id++;
}
return `user-${id}`; // O(1) most of the time
}
async getAll() {
return { nodes: this.nodes }
}
}