Add sorting
This commit is contained in:
@@ -3,51 +3,53 @@ import mongoose from "mongoose";
|
||||
import { buildJsonSchemas } from "fastify-zod";
|
||||
import { pageMetadata, pageQueryParams } from "../pagination";
|
||||
|
||||
export const permitModel = mongoose.model(
|
||||
"permit",
|
||||
new mongoose.Schema({
|
||||
tenantId: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
pid: {
|
||||
type: String,
|
||||
unique: true,
|
||||
},
|
||||
permitNumber: String,
|
||||
county: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
client: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
permitDate: Date,
|
||||
stage: String,
|
||||
status: String,
|
||||
assignedTo: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "user",
|
||||
},
|
||||
link: String,
|
||||
address: String,
|
||||
recordType: String,
|
||||
description: String,
|
||||
applicationDetails: Object,
|
||||
applicationInfo: Object,
|
||||
applicationInfoTable: Object,
|
||||
conditions: Array,
|
||||
ownerDetails: String,
|
||||
parcelInfo: Object,
|
||||
paymentData: Object,
|
||||
professionalsList: Array,
|
||||
inspections: Object,
|
||||
createdAt: Date,
|
||||
updatedAt: Date,
|
||||
createdBy: String,
|
||||
}).index({ tenantId: 1, permitNumber: 1 }, { unique: true })
|
||||
const permitSchema = new mongoose.Schema({
|
||||
tenantId: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
pid: {
|
||||
type: String,
|
||||
unique: true,
|
||||
},
|
||||
permitNumber: String,
|
||||
county: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
client: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "organization",
|
||||
},
|
||||
permitDate: Date,
|
||||
stage: String,
|
||||
status: String,
|
||||
assignedTo: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "user",
|
||||
},
|
||||
link: String,
|
||||
address: String,
|
||||
recordType: String,
|
||||
description: String,
|
||||
applicationDetails: Object,
|
||||
applicationInfo: Object,
|
||||
applicationInfoTable: Object,
|
||||
conditions: Array,
|
||||
ownerDetails: String,
|
||||
parcelInfo: Object,
|
||||
paymentData: Object,
|
||||
professionalsList: Array,
|
||||
inspections: Object,
|
||||
createdAt: Date,
|
||||
updatedAt: Date,
|
||||
createdBy: String,
|
||||
}).index({ tenantId: 1, permitNumber: 1 }, { unique: true });
|
||||
|
||||
export const permitFields = Object.keys(permitSchema.paths).filter(
|
||||
(path) => path !== "__v"
|
||||
);
|
||||
export const permitModel = mongoose.model("permit", permitSchema);
|
||||
|
||||
const permitCore = {
|
||||
permitNumber: z.string(),
|
||||
|
||||
Reference in New Issue
Block a user