From 365e119a11a5be2a8ff2a6620da413d59921feff Mon Sep 17 00:00:00 2001 From: sudjoao Date: Wed, 27 Sep 2023 18:25:42 -0300 Subject: [PATCH] chore: limit user find by name --- src/repository/SocialNetworkRepository.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/repository/SocialNetworkRepository.js b/src/repository/SocialNetworkRepository.js index 93278844..28274e2c 100644 --- a/src/repository/SocialNetworkRepository.js +++ b/src/repository/SocialNetworkRepository.js @@ -53,7 +53,7 @@ class SocialNetworkRepository extends BaseRepository { await super.$update(socialNetworkProfile); } - async findUsersbyName(userProfileId, userName) { + async findUsersbyName(userProfileId, userName, limit = 20) { const query = { _id: { $ne: ObjectID(userProfileId) }, username: { $regex: userName, $options: 'i' }, @@ -66,7 +66,7 @@ class SocialNetworkRepository extends BaseRepository { select: ['photo', 'cnpj', 'cpf'], }; - const users = await super.$list(query, selectField, populate); + const users = await super.$list(query, selectField, populate, null, limit); const mappedUsers = users.map((user) => mapSocialNetworkUser(user, userProfileId));