diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/user.ts | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index e56b0bf40..39654cfcf 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -181,7 +181,25 @@ export class UserModel extends Model<UserModel> { | |||
181 | return this.count() | 181 | return this.count() |
182 | } | 182 | } |
183 | 183 | ||
184 | static listForApi (start: number, count: number, sort: string) { | 184 | static listForApi (start: number, count: number, sort: string, search?: string) { |
185 | let where = undefined | ||
186 | if (search) { | ||
187 | where = { | ||
188 | [Sequelize.Op.or]: [ | ||
189 | { | ||
190 | email: { | ||
191 | [Sequelize.Op.iLike]: '%' + search + '%' | ||
192 | } | ||
193 | }, | ||
194 | { | ||
195 | username: { | ||
196 | [ Sequelize.Op.iLike ]: '%' + search + '%' | ||
197 | } | ||
198 | } | ||
199 | ] | ||
200 | } | ||
201 | } | ||
202 | |||
185 | const query = { | 203 | const query = { |
186 | attributes: { | 204 | attributes: { |
187 | include: [ | 205 | include: [ |
@@ -204,7 +222,8 @@ export class UserModel extends Model<UserModel> { | |||
204 | }, | 222 | }, |
205 | offset: start, | 223 | offset: start, |
206 | limit: count, | 224 | limit: count, |
207 | order: getSort(sort) | 225 | order: getSort(sort), |
226 | where | ||
208 | } | 227 | } |
209 | 228 | ||
210 | return UserModel.findAndCountAll(query) | 229 | return UserModel.findAndCountAll(query) |