database basically working
This commit is contained in:
36
server/db/model/edge.js
Normal file
36
server/db/model/edge.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export default class Edge {
|
||||
schema = z.object({
|
||||
id: z.number(),
|
||||
from: z.string(),
|
||||
to: z.string(),
|
||||
created: z.string()
|
||||
})
|
||||
.strict()
|
||||
|
||||
save(n, id) {
|
||||
let result = this.schema.safeParse(n)
|
||||
if(result.success) {
|
||||
try {
|
||||
super.add(id, n)
|
||||
} catch(e) {
|
||||
console.error(e)
|
||||
throw e
|
||||
}
|
||||
} else {
|
||||
console.error(result.error)
|
||||
throw new global.ServerError(400, "Invalid Member Data!");
|
||||
}
|
||||
}
|
||||
|
||||
getByFrom(fromID) {
|
||||
let result = []
|
||||
for(let i = 0; i < this.entries.length; i++) {
|
||||
if(entries[i].from === fromID) {
|
||||
// let
|
||||
}
|
||||
}
|
||||
console.log(fromID)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user