Files
frm.so/server/db/schemas.js
matiasc18 aaf9d56b1b CRUD operations for Posts
- added all CRUD operations for Post model
- add() also creates POST_BY_MEMBER and POST_FROM_NETWORK edges
- delete() also deletes associated edges
- delete() currently does not reallocate node/edge indices after deleting
- will write the data to the db.json file and global.db.nodes
2026-02-08 22:34:18 -05:00

76 lines
1.6 KiB
JavaScript

import { z } from 'zod';
export let addressSchema = z.object({
address1: z.string(),
address2: z.string().optional(),
zip: z.string().regex(/^\d{5}(-\d{4})?$/),
state: z.string(),
city: z.string()
})
export let MEMBER = z.object({
id: z.number(),
email: z.string().email(),
firstName: z.string(),
lastName: z.string(),
password: z.string(),
tokenUsed: z.string().regex(
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
"Invalid UUID"
),
joined: z.string(),
address: addressSchema
})
export let NETWORK = z.object({
id: z.number(),
name: z.string(),
apps: z.array(z.string()),
logo: z.string()
})
.strict()
export let TITLE = z.object({
id: z.number(),
name: z.string(),
apps: z.array(z.string()),
logo: z.string()
})
.strict()
export let PAYMENT = z.object({
id: z.number(),
name: z.string(),
email: z.string(),
time: z.string(),
amount: z.number(),
product: z.string(),
})
export let POST = z.object({
id: z.number(),
text: z.string(),
time: z.string(),
sentBy: z.string(),
edited: z.boolean()
})
export let CONVSRSATION = z.object({
id: z.number(),
between: z.array(z.string()),
lastUpdated: z.string()
}).strict()
export let DM = z.object({
id: z.number(),
conversation: z.string(),
from: z.string(),
text: z.string(),
time: z.string()
}).strict()
export let MEMBER_IN_NETWORK = z.object({
id: z.number(),
from: z.string(),
to: z.string(),
created: z.string()
}).strict()