[Server] Some performance improvements
This commit is contained in:
parent
e52965a923
commit
1f88c4d40c
14 changed files with 74 additions and 8 deletions
|
|
@ -34,15 +34,22 @@ export default (
|
|||
|
||||
let _user: any;
|
||||
|
||||
const fields = opts.detail ? {
|
||||
data: false
|
||||
} : {
|
||||
data: false,
|
||||
profile: false
|
||||
};
|
||||
|
||||
// Populate the user if 'user' is ID
|
||||
if (mongo.ObjectID.prototype.isPrototypeOf(user)) {
|
||||
_user = await User.findOne({
|
||||
_id: user
|
||||
});
|
||||
}, { fields });
|
||||
} else if (typeof user === 'string') {
|
||||
_user = await User.findOne({
|
||||
_id: new mongo.ObjectID(user)
|
||||
});
|
||||
}, { fields });
|
||||
} else {
|
||||
_user = deepcopy(user);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue