Add sorting

This commit is contained in:
2025-01-02 11:19:44 +05:30
parent 40b2ab54f0
commit 83786e2994
5 changed files with 109 additions and 70 deletions

View File

@@ -3,30 +3,32 @@ import mongoose from "mongoose";
import { z } from "zod";
import { pageMetadata, pageQueryParams } from "../pagination";
export const orgModel = mongoose.model(
"organization",
new mongoose.Schema({
tenantId: {
type: String,
required: true,
},
pid: {
type: String,
unique: true,
},
name: String,
domain: {
type: String,
},
avatar: String,
const orgSchema = new mongoose.Schema({
tenantId: {
type: String,
isClient: Boolean,
status: String,
createdAt: Date,
createdBy: String,
updatedAt: Date,
}).index({ tenantId: 1, domain: 1 }, { unique: true })
required: true,
},
pid: {
type: String,
unique: true,
},
name: String,
domain: {
type: String,
},
avatar: String,
type: String,
isClient: Boolean,
status: String,
createdAt: Date,
createdBy: String,
updatedAt: Date,
}).index({ tenantId: 1, domain: 1 }, { unique: true });
export const orgFields = Object.keys(orgSchema.paths).filter(
(path) => path !== "__v"
);
export const orgModel = mongoose.model("organization", orgSchema);
const orgCore = {
name: z.string().max(30),