Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 54x 692x 692x 54x 54x 63x 63x 54x 54x | import mongoose from "mongoose";
import { z } from "zod";
import dayjs from "dayjs";
const UserSignupsSchema = z.object({
username: z.string(),
priority: z.number(),
signedToStartTime: z.date().transform((date) => dayjs(date).toISOString()),
signupTime: z.date().transform((date) => dayjs(date).toISOString()),
message: z.string(),
});
export const DirectSignupSchemaDb = z
.object({
programItemId: z.string(),
userSignups: z.array(UserSignupsSchema),
count: z.number(),
})
.strip();
const userSignupSchema = new mongoose.Schema({
username: { type: String, required: true },
priority: { type: Number, required: true },
signedToStartTime: {
type: Date,
get: (value: Date) => new Date(value),
required: true,
},
// Timestamp recording when the user signed up
signupTime: {
type: Date,
get: (value: Date) => new Date(value),
required: true,
},
message: { type: String, required: true },
});
const directSignupSchema = new mongoose.Schema(
{
programItemId: { type: String, required: true },
userSignups: { type: [userSignupSchema], required: true },
count: { type: Number, default: 0 },
},
{ timestamps: true },
);
export const SignupModel = mongoose.model("direct-signup", directSignupSchema);
|