schmea changes, removed notes
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const noteSchema = new mongoose.Schema({
|
||||
resourceId: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
required: true,
|
||||
},
|
||||
content: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
createdAt: Date,
|
||||
createdBy: {
|
||||
type: mongoose.Types.ObjectId,
|
||||
ref: "user",
|
||||
},
|
||||
});
|
||||
|
||||
export const noteModel = mongoose.model("note", noteSchema);
|
||||
@@ -31,6 +31,54 @@ 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,
|
||||
statusPipeline: 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",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$facet: {
|
||||
metadata: [{ $count: "count" }],
|
||||
|
||||
@@ -96,6 +96,7 @@ export async function listRts(params: PageQueryParams, tenantId: string) {
|
||||
pid: "$$county.pid",
|
||||
name: "$$county.name",
|
||||
type: "$$county.type",
|
||||
avatar: "$$county.avatar",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -107,6 +108,7 @@ export async function listRts(params: PageQueryParams, tenantId: string) {
|
||||
pid: "$$client.pid",
|
||||
name: "$$client.name",
|
||||
type: "$$client.type",
|
||||
avatar: "$$client.avatar",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user