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)
    }
}