From 57c97e1ed6ab0c849f4e99830d7820b0b78096cc Mon Sep 17 00:00:00 2001 From: Akhil Meka Date: Thu, 6 Mar 2025 16:15:45 +0530 Subject: [PATCH] notification schema change --- src/notification/notification.schema.ts | 15 +++----- src/notification/notification.service.ts | 49 ++++-------------------- 2 files changed, 14 insertions(+), 50 deletions(-) diff --git a/src/notification/notification.schema.ts b/src/notification/notification.schema.ts index 6abe40a..b9696c7 100644 --- a/src/notification/notification.schema.ts +++ b/src/notification/notification.schema.ts @@ -8,19 +8,16 @@ const notificationSchema = new mongoose.Schema({ type: String, unique: true, }, + permitId: mongoose.Types.ObjectId, tenantId: String, permitNumber: String, - permitLink: String, + link: String, status: String, + accelaStatus: String, changes: Object, - county: { - type: mongoose.Types.ObjectId, - ref: "organization", - }, - client: { - type: mongoose.Types.ObjectId, - ref: "organization", - }, + county: Object, + client: mongoose.Types.ObjectId, + clientData: Object, createdAt: Date, updatedAt: Date, }); diff --git a/src/notification/notification.service.ts b/src/notification/notification.service.ts index 8e0995f..c96908c 100644 --- a/src/notification/notification.service.ts +++ b/src/notification/notification.service.ts @@ -31,55 +31,22 @@ export async function listNotifications( const notifications = await notificationModel.aggregate([ { $match: { $and: [{ tenantId: tenantId }, ...filterObj] } }, - { - $lookup: { - from: "organizations", - localField: "county", - foreignField: "_id", - as: "countyRec", - }, - }, - { - $lookup: { - from: "organizations", - localField: "client", - foreignField: "_id", - as: "clientRec", - }, - }, { $project: { _id: 1, pid: 1, + permitId: 1, + tenantId: 1, permitNumber: 1, - permitLink: 1, + link: 1, status: 1, + accelaStatus: 1, changes: 1, + county: 1, + client: 1, + clientData: 1, createdAt: 1, - county: { - $let: { - vars: { county: { $arrayElemAt: ["$countyRec", 0] } }, - in: { - _id: "$$county._id", - pid: "$$county.pid", - name: "$$county.name", - type: "$$county.type", - avatar: "$$county.avatar", - }, - }, - }, - client: { - $let: { - vars: { client: { $arrayElemAt: ["$clientRec", 0] } }, - in: { - _id: "$$client._id", - pid: "$$client.pid", - name: "$$client.name", - type: "$$client.type", - avatar: "$$client.avatar", - }, - }, - }, + updatedAt: 1, }, }, {