core: fix getDomainUser

This commit is contained in:
undefined committed 2021-03-16 22:28:07 +08:00
1 parent 0bed88ff99
commit aa096322c3
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.20.22", "version": "2.20.23",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+2 -2
View File
@@ -89,7 +89,7 @@ class DomainModel {
const res = await coll.findOneAndUpdate( const res = await coll.findOneAndUpdate(
{ _id: domainId }, { _id: domainId },
// FIXME // FIXME
// @ts-ignore // @ts-expect-error
{ $inc: { [field]: n } }, { $inc: { [field]: n } },
{ returnOriginal: false }, { returnOriginal: false },
); );
@@ -182,7 +182,7 @@ class DomainModel {
@ArgMethod @ArgMethod
static async incUserInDomain(domainId: string, uid: number, field: string, n: number = 1) { static async incUserInDomain(domainId: string, uid: number, field: string, n: number = 1) {
// @ts-ignore // @ts-ignore
const dudoc = await getDomainUser(domainId, { _id: uid }); const dudoc = await DomainModel.getDomainUser(domainId, { _id: uid });
dudoc[field] = dudoc[field] + n || n; dudoc[field] = dudoc[field] + n || n;
await DomainModel.setUserInDomain(domainId, uid, { [field]: dudoc[field] }); await DomainModel.setUserInDomain(domainId, uid, { [field]: dudoc[field] });
return dudoc; return dudoc;