core: limit sdoc payload

This commit is contained in:
undefined committed 2022-07-27 21:40:12 +08:00
1 parent 22201794ce
commit 340b02bbf2
4 files changed
+8 -11

No files matched your search

+5 -2
View File
@@ -82,8 +82,11 @@ class TokenModel {
}
@ArgMethod
static async getMostRecentSessionByUid(uid: number) {
return await TokenModel.coll.findOne({ uid, tokenType: TokenModel.TYPE_SESSION }, { sort: { updateAt: -1 } });
static async getMostRecentSessionByUid(uid: number, projection: string[]) {
return await TokenModel.coll.findOne(
{ uid, tokenType: TokenModel.TYPE_SESSION },
{ projection: { _id: 0, ...Object.fromEntries(projection.map((i) => [i, 1])) }, sort: { updateAt: -1 } },
);
}
@ArgMethod