feat: custom unique values for taggedUsers field, set the latest taggedUser to assigendTo field
This commit is contained in:
@@ -2,6 +2,7 @@ import { orgModel } from "./organization/organization.schema";
|
||||
import { userModel } from "./user/user.schema";
|
||||
import { AuthenticatedUser } from "./auth";
|
||||
import { modelMap } from "./utils/tags";
|
||||
import { listUsers } from "./user/user.service";
|
||||
|
||||
type Collection =
|
||||
| "users"
|
||||
@@ -32,6 +33,17 @@ export async function getUniqueFields(
|
||||
return changeKeys.map((item) => item._id);
|
||||
}
|
||||
|
||||
if (field === "taggedUsers") {
|
||||
const users = await listUsers(user);
|
||||
const usersObj = {};
|
||||
|
||||
for (const user of users) {
|
||||
usersObj[user.id] = user.name;
|
||||
}
|
||||
|
||||
return usersObj;
|
||||
}
|
||||
|
||||
let values = await model.distinct(field, { tenantId: user.tenantId });
|
||||
|
||||
let matchedValues = [];
|
||||
|
||||
Reference in New Issue
Block a user