added default views routes

This commit is contained in:
2025-05-20 16:30:02 +05:30
parent 690f8c71de
commit f0593fd928
4 changed files with 108 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
import { buildJsonSchemas } from "fastify-zod";
import mongoose from "mongoose";
import { z } from "zod";
import { TypeOf, z } from "zod";
import { pageQueryParams } from "../pagination";
export const viewModel = mongoose.model(
@@ -54,11 +54,28 @@ const updateViewInput = z.object({
export type CreateViewInput = z.infer<typeof createViewInput>;
export type UpdateViewInput = z.infer<typeof updateViewInput>;
export const defaultViewModel = mongoose.model(
"defaultView",
new mongoose.Schema({
userId: {
type: mongoose.Types.ObjectId,
ref: "user",
},
defaultViews: Object,
}),
"defaultView"
);
const setDefaultView = z.record(z.string(), z.string());
export type SetDefaultView = z.infer<typeof setDefaultView>;
export const { schemas: viewSchemas, $ref: $view } = buildJsonSchemas(
{
createViewInput,
updateViewInput,
pageQueryParams,
setDefaultView,
},
{ $id: "view" }
);