This commit is contained in:
undefined committed 2020-07-30 23:09:03 +08:00
1 parent 51dc2e972d
commit 43ee86d34b
17 files changed
+177 -88

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ export const pdocHidden: Pdoc = {
content: '',
nSubmit: 0,
nAccept: 0,
difficulty: 0,
tag: [],
category: [],
data: null,
+10 -4
View File
@@ -109,14 +109,20 @@ export function getMulti(domainId: string, query: any) {
export async function update(
domainId: string, _id: ObjectID,
$set: any = {}, $push: any = {}, $unset: any = {},
): Promise<Rdoc> {
): Promise<Rdoc | null> {
const $update: any = {};
if ($set && Object.keys($set).length) $update.$set = $set;
if ($push && Object.keys($push).length) $update.$push = $push;
if ($unset && Object.keys($unset).length) $update.$unset = $unset;
const res = await coll.findOneAndUpdate({ domainId, _id }, $update, { returnOriginal: false });
if (!res.value) throw new RecordNotFoundError(_id);
return res.value;
if (Object.keys($update).length) {
const res = await coll.findOneAndUpdate(
{ _id, domainId },
$update,
{ returnOriginal: false },
);
return res.value;
}
return await get(domainId, _id);
}
export function reset(domainId: string, rid: ObjectID, isRejudge: boolean) {
+1 -1
View File
@@ -107,7 +107,7 @@ DomainUserSetting(
Setting('setting_storage', 'nAccept', null, 0, 'number', 'nAccept', null, FLAG_HIDDEN | FLAG_DISABLED),
Setting('setting_storage', 'nSubmit', null, 0, 'number', 'nSubmit', null, FLAG_HIDDEN | FLAG_DISABLED),
Setting('setting_storage', 'nLike', null, 0, 'number', 'nLike', null, FLAG_HIDDEN | FLAG_DISABLED),
Setting('setting_storage', 'rating', null, 1500, 'number', 'rating', null, FLAG_HIDDEN | FLAG_DISABLED),
Setting('setting_storage', 'rp', null, 1500, 'number', 'RP', null, FLAG_HIDDEN | FLAG_DISABLED),
);
SystemSetting(