notification schema change
This commit is contained in:
@@ -8,19 +8,16 @@ const notificationSchema = new mongoose.Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
unique: true,
|
||||||
},
|
},
|
||||||
|
permitId: mongoose.Types.ObjectId,
|
||||||
tenantId: String,
|
tenantId: String,
|
||||||
permitNumber: String,
|
permitNumber: String,
|
||||||
permitLink: String,
|
link: String,
|
||||||
status: String,
|
status: String,
|
||||||
|
accelaStatus: String,
|
||||||
changes: Object,
|
changes: Object,
|
||||||
county: {
|
county: Object,
|
||||||
type: mongoose.Types.ObjectId,
|
client: mongoose.Types.ObjectId,
|
||||||
ref: "organization",
|
clientData: Object,
|
||||||
},
|
|
||||||
client: {
|
|
||||||
type: mongoose.Types.ObjectId,
|
|
||||||
ref: "organization",
|
|
||||||
},
|
|
||||||
createdAt: Date,
|
createdAt: Date,
|
||||||
updatedAt: Date,
|
updatedAt: Date,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,55 +31,22 @@ export async function listNotifications(
|
|||||||
|
|
||||||
const notifications = await notificationModel.aggregate([
|
const notifications = await notificationModel.aggregate([
|
||||||
{ $match: { $and: [{ tenantId: tenantId }, ...filterObj] } },
|
{ $match: { $and: [{ tenantId: tenantId }, ...filterObj] } },
|
||||||
{
|
|
||||||
$lookup: {
|
|
||||||
from: "organizations",
|
|
||||||
localField: "county",
|
|
||||||
foreignField: "_id",
|
|
||||||
as: "countyRec",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$lookup: {
|
|
||||||
from: "organizations",
|
|
||||||
localField: "client",
|
|
||||||
foreignField: "_id",
|
|
||||||
as: "clientRec",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
$project: {
|
$project: {
|
||||||
_id: 1,
|
_id: 1,
|
||||||
pid: 1,
|
pid: 1,
|
||||||
|
permitId: 1,
|
||||||
|
tenantId: 1,
|
||||||
permitNumber: 1,
|
permitNumber: 1,
|
||||||
permitLink: 1,
|
link: 1,
|
||||||
status: 1,
|
status: 1,
|
||||||
|
accelaStatus: 1,
|
||||||
changes: 1,
|
changes: 1,
|
||||||
|
county: 1,
|
||||||
|
client: 1,
|
||||||
|
clientData: 1,
|
||||||
createdAt: 1,
|
createdAt: 1,
|
||||||
county: {
|
updatedAt: 1,
|
||||||
$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",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user