diff --git a/server/models/Document.ts b/server/models/Document.ts index af44aa21ce..7ca891878b 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -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): Promise => { - const users = await Promise.all( - this.collaboratorIds.map((collaboratorId) => - User.findByPk(collaboratorId, options) - ) - ); - - return compact(users); - }; + collaborators = async (options?: FindOptions): Promise => + await User.findAll({ + ...options, + where: { + ...options?.where, + id: this.collaboratorIds, + }, + }); /** * Find all of the child documents for this document