diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 13:08:33 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 13:08:33 +0900 |
| commit | 1f88c4d40c3e6dba6da173496e444e46323d84c5 (patch) | |
| tree | d1bc4b51f24c7e3c5fa89503470f7ea6d9628696 /src/api/serializers | |
| parent | Remove unused import (diff) | |
| download | sharkey-1f88c4d40c3e6dba6da173496e444e46323d84c5.tar.gz sharkey-1f88c4d40c3e6dba6da173496e444e46323d84c5.tar.bz2 sharkey-1f88c4d40c3e6dba6da173496e444e46323d84c5.zip | |
[Server] Some performance improvements
Diffstat (limited to 'src/api/serializers')
| -rw-r--r-- | src/api/serializers/user.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/api/serializers/user.ts b/src/api/serializers/user.ts index 945c01d258..8bab540a5c 100644 --- a/src/api/serializers/user.ts +++ b/src/api/serializers/user.ts @@ -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); } |