mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
perf: use findAll for querying document collaborators (#7697)
* perf: use findAll for querying document collaborators * remove unnecessary compact
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user