add notification routes
This commit is contained in:
50
src/notification/notification.schema.ts
Normal file
50
src/notification/notification.schema.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { buildJsonSchemas } from "fastify-zod";
|
||||
import mongoose from "mongoose";
|
||||
import { z } from "zod";
|
||||
import { pageQueryParams } from "../pagination";
|
||||
|
||||
const notificationSchema = new mongoose.Schema({
|
||||
pid: {
|
||||
type: String,
|
||||
unique: true,
|
||||
},
|
||||
tenantId: String,
|
||||
permitNumber: String,
|
||||
permitLink: String,
|
||||
status: String,
|
||||
changes: Object,
|
||||
county: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
client: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
createdAt: Date,
|
||||
updatedAt: Date,
|
||||
});
|
||||
|
||||
export const notificationFields = Object.keys(notificationSchema.paths).filter(
|
||||
(path) => path !== "__v"
|
||||
);
|
||||
|
||||
export const notificationModel = mongoose.model(
|
||||
"notification",
|
||||
notificationSchema
|
||||
);
|
||||
|
||||
const updateNotificationInput = z.object({
|
||||
status: z.string(),
|
||||
});
|
||||
|
||||
export type UpdateNotificationInput = z.infer<typeof updateNotificationInput>;
|
||||
|
||||
export const { schemas: notificationSchemas, $ref: $notification } =
|
||||
buildJsonSchemas(
|
||||
{
|
||||
updateNotificationInput,
|
||||
pageQueryParams,
|
||||
},
|
||||
{ $id: "notification" }
|
||||
);
|
||||
Reference in New Issue
Block a user