added array filter option
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { orgModel } from '../organization/organization.schema';
|
||||
import { getFilterObject, getSortObject, PageQueryParams } from '../pagination';
|
||||
import { userModel } from '../user/user.schema';
|
||||
import { generateId } from '../utils/id';
|
||||
import { orgModel } from "../organization/organization.schema";
|
||||
import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
|
||||
import { userModel } from "../user/user.schema";
|
||||
import { generateId } from "../utils/id";
|
||||
import {
|
||||
CreateNotificationInput,
|
||||
notificationFields,
|
||||
notificationModel,
|
||||
UpdateNotificationInput,
|
||||
} from './notification.schema';
|
||||
} from "./notification.schema";
|
||||
|
||||
export async function createNotification(
|
||||
input: CreateNotificationInput,
|
||||
@@ -47,12 +47,12 @@ export async function listNotifications(
|
||||
|
||||
const pipeline: any = [
|
||||
{
|
||||
$match: { $and: [{ tenantId: tenantId }, { ...filterObj }] },
|
||||
$match: { $and: [{ tenantId: tenantId }, ...filterObj] },
|
||||
},
|
||||
];
|
||||
|
||||
if (params.searchToken && params.searchToken != '') {
|
||||
const regex = new RegExp(params.searchToken, 'i');
|
||||
if (params.searchToken && params.searchToken != "") {
|
||||
const regex = new RegExp(params.searchToken, "i");
|
||||
pipeline.push({
|
||||
$match: {
|
||||
$or: [{ permitNumber: { $regex: regex } }, { link: { $regex: regex } }],
|
||||
@@ -82,7 +82,7 @@ export async function listNotifications(
|
||||
},
|
||||
{
|
||||
$facet: {
|
||||
metadata: [{ $count: 'count' }],
|
||||
metadata: [{ $count: "count" }],
|
||||
data: [
|
||||
{ $sort: sortObj },
|
||||
{ $skip: (page - 1) * pageSize },
|
||||
@@ -121,12 +121,12 @@ export async function getUniqueValuesNotification(
|
||||
let values = await notificationModel.distinct(field, { tenantId: tenenatId });
|
||||
|
||||
let matchedValues = [];
|
||||
if (field === 'county.name') {
|
||||
matchedValues = await orgModel.find().where('name').in(values).exec();
|
||||
} else if (field === 'client') {
|
||||
matchedValues = await orgModel.find().where('_id').in(values).exec();
|
||||
} else if (field === 'assignedTo') {
|
||||
matchedValues = await userModel.find().where('name').in(values).exec();
|
||||
if (field === "county.name") {
|
||||
matchedValues = await orgModel.find().where("name").in(values).exec();
|
||||
} else if (field === "client") {
|
||||
matchedValues = await orgModel.find().where("_id").in(values).exec();
|
||||
} else if (field === "assignedTo") {
|
||||
matchedValues = await userModel.find().where("name").in(values).exec();
|
||||
}
|
||||
|
||||
if (matchedValues.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user