Compare commits

...

2 Commits

Author SHA1 Message Date
hmacr 36590a8fa4 remove unnecessary compact 2024-09-29 22:02:29 +05:30
hmacr 9d31eee382 perf: use findAll for querying document collaborators 2024-09-29 21:36:53 +05:30
+8 -9
View File
@@ -807,15 +807,14 @@ class Document extends ParanoidModel<
* @param options FindOptions
* @returns A promise that resolve to a list of users
*/
collaborators = async (options?: FindOptions<User>): Promise<User[]> => {
const users = await Promise.all(
this.collaboratorIds.map((collaboratorId) =>
User.findByPk(collaboratorId, options)
)
);
return compact(users);
};
collaborators = async (options?: FindOptions<User>): Promise<User[]> =>
await User.findAll({
...options,
where: {
...options?.where,
id: this.collaboratorIds,
},
});
/**
* Find all of the child documents for this document