optimize autocomplete regex

This commit is contained in:
Phillip Thelen
2019-02-12 14:38:45 +01:00
parent bb674d1539
commit 3fec6fca0e

View File

@@ -23,7 +23,7 @@ api.getUsernameAutocompletes = {
} }
let members = await User let members = await User
.find({'auth.local.lowerCaseUsername': {$regex: `.*${username}.*`}, 'flags.verifiedUsername': true, 'preferences.searchableUsername': {$ne: false}}) .find({'auth.local.lowerCaseUsername': {$regex: `^${username}.*`}, 'flags.verifiedUsername': true, 'preferences.searchableUsername': {$ne: false}})
.select(['profile.name', 'contributor', 'auth.local.username']) .select(['profile.name', 'contributor', 'auth.local.username'])
.limit(20) .limit(20)
.exec(); .exec();