[Server] Some performance improvements
This commit is contained in:
parent
e52965a923
commit
1f88c4d40c
14 changed files with 74 additions and 8 deletions
|
|
@ -38,10 +38,16 @@ module.exports = (params, me) =>
|
|||
return rej('incorrect user_id');
|
||||
}
|
||||
|
||||
const q = userId != null
|
||||
? { _id: new mongo.ObjectID(userId) }
|
||||
: { username_lower: username.toLowerCase() } ;
|
||||
|
||||
// Lookup user
|
||||
const user = userId !== null
|
||||
? await User.findOne({ _id: new mongo.ObjectID(userId) })
|
||||
: await User.findOne({ username_lower: username.toLowerCase() });
|
||||
const user = await User.findOne(q, {
|
||||
fields: {
|
||||
data: false
|
||||
}
|
||||
});
|
||||
|
||||
if (user === null) {
|
||||
return rej('user not found');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue