Improved the performance of the MasterCorporate
This commit is contained in:
@@ -44,7 +44,15 @@ export async function getSpecificUsers(ids: string[]) {
|
||||
.toArray();
|
||||
}
|
||||
|
||||
export async function getLinkedUsers(userID?: string, userType?: Type, type?: Type, page?: number, size?: number) {
|
||||
export async function getLinkedUsers(
|
||||
userID?: string,
|
||||
userType?: Type,
|
||||
type?: Type,
|
||||
page?: number,
|
||||
size?: number,
|
||||
sort?: string,
|
||||
direction?: "asc" | "desc",
|
||||
) {
|
||||
const filters = {
|
||||
...(!!type ? {type} : {}),
|
||||
};
|
||||
@@ -53,6 +61,7 @@ export async function getLinkedUsers(userID?: string, userType?: Type, type?: Ty
|
||||
const users = await db
|
||||
.collection("users")
|
||||
.find<User>(filters)
|
||||
.sort(sort ? {[sort]: direction === "desc" ? -1 : 1} : {})
|
||||
.skip(page && size ? page * size : 0)
|
||||
.limit(size || 0)
|
||||
.toArray();
|
||||
|
||||
Reference in New Issue
Block a user