Comparing version 2.13.29 to 2.13.30
@@ -55,3 +55,3 @@ "use strict"; | ||
time: body.case.time, | ||
message: body.case.message, | ||
message: body.case.message || '', | ||
status: body.case.status, | ||
@@ -58,0 +58,0 @@ }; |
@@ -24,3 +24,3 @@ import { Dictionary } from 'lodash'; | ||
export declare function getMulti(query?: FilterQuery<DomainDoc>): import("mongodb").Cursor<DomainDoc>; | ||
export declare function edit(domainId: string, $set: Partial<DomainDoc>): Promise<import("mongodb").UpdateWriteOpResult>; | ||
export declare function edit(domainId: string, $set: Partial<DomainDoc>): Promise<DomainDoc>; | ||
export declare function inc(domainId: string, field: keyof DomainDoc, n: number): Promise<number | null>; | ||
@@ -27,0 +27,0 @@ export declare function getList(domainIds: string[]): Promise<Dictionary<DomainDoc>>; |
@@ -24,2 +24,3 @@ "use strict"; | ||
const builtin_1 = require("./builtin"); | ||
const bus = __importStar(require("../service/bus")); | ||
const db = __importStar(require("../service/db")); | ||
@@ -57,2 +58,3 @@ const coll = db.collection('domain'); | ||
}; | ||
await bus.serial('domain/create', ddoc); | ||
await coll.insertOne(ddoc); | ||
@@ -62,4 +64,8 @@ return domainId; | ||
exports.add = add; | ||
function get(domainId) { | ||
return coll.findOne({ _id: domainId }); | ||
async function get(domainId) { | ||
const query = { _id: domainId }; | ||
await bus.serial('domain/before-get', query); | ||
const result = await coll.findOne(query); | ||
await bus.serial('domain/get', result); | ||
return result; | ||
} | ||
@@ -71,4 +77,7 @@ exports.get = get; | ||
exports.getMulti = getMulti; | ||
function edit(domainId, $set) { | ||
return coll.updateOne({ _id: domainId }, { $set }); | ||
async function edit(domainId, $set) { | ||
await bus.serial('domain/before-update', domainId, $set); | ||
const result = await coll.findOneAndUpdate({ _id: domainId }, { $set }, { returnOriginal: false }); | ||
await bus.serial('domain/update', domainId, $set, result.value); | ||
return result.value; | ||
} | ||
@@ -75,0 +84,0 @@ exports.edit = edit; |
import { Db, FilterQuery } from 'mongodb'; | ||
import { Mdoc, Pdoc, Rdoc, TrainingDoc, User } from '../interface'; | ||
import { DomainDoc } from '../loader'; | ||
declare type DocType = import('../model/document').DocType; | ||
@@ -22,2 +23,7 @@ export declare type Disposable = () => void; | ||
'user/get': (udoc: User) => void; | ||
'domain/create': (ddoc: DomainDoc) => VoidReturn; | ||
'domain/before-get': (query: FilterQuery<DomainDoc>) => VoidReturn; | ||
'domain/get': (ddoc: DomainDoc) => VoidReturn; | ||
'domain/before-update': (domainId: string, $set: Partial<DomainDoc>) => VoidReturn; | ||
'domain/update': (domainId: string, $set: Partial<DomainDoc>, ddoc: DomainDoc) => VoidReturn; | ||
'document/add': (doc: any) => VoidReturn; | ||
@@ -24,0 +30,0 @@ 'document/set': <T extends keyof DocType>(domainId: string, docType: T, docId: DocType[T], $set: any) => VoidReturn; |
{ | ||
"name": "hydrooj", | ||
"version": "2.13.29", | ||
"version": "2.13.30", | ||
"bin": "bin/hydrooj.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/loader.js", |
@@ -45,3 +45,3 @@ import { ObjectID } from 'mongodb'; | ||
time: body.case.time, | ||
message: body.case.message, | ||
message: body.case.message || '', | ||
status: body.case.status, | ||
@@ -48,0 +48,0 @@ }; |
@@ -5,2 +5,3 @@ import { Dictionary } from 'lodash'; | ||
import { DomainDoc } from '../interface'; | ||
import * as bus from '../service/bus'; | ||
import * as db from '../service/db'; | ||
@@ -43,2 +44,3 @@ | ||
}; | ||
await bus.serial('domain/create', ddoc); | ||
await coll.insertOne(ddoc); | ||
@@ -48,4 +50,8 @@ return domainId; | ||
export function get(domainId: string): Promise<DomainDoc | null> { | ||
return coll.findOne({ _id: domainId }); | ||
export async function get(domainId: string): Promise<DomainDoc | null> { | ||
const query: FilterQuery<DomainDoc> = { _id: domainId }; | ||
await bus.serial('domain/before-get', query); | ||
const result = await coll.findOne(query); | ||
await bus.serial('domain/get', result); | ||
return result; | ||
} | ||
@@ -57,4 +63,7 @@ | ||
export function edit(domainId: string, $set: Partial<DomainDoc>) { | ||
return coll.updateOne({ _id: domainId }, { $set }); | ||
export async function edit(domainId: string, $set: Partial<DomainDoc>) { | ||
await bus.serial('domain/before-update', domainId, $set); | ||
const result = await coll.findOneAndUpdate({ _id: domainId }, { $set }, { returnOriginal: false }); | ||
await bus.serial('domain/update', domainId, $set, result.value); | ||
return result.value; | ||
} | ||
@@ -61,0 +70,0 @@ |
@@ -9,2 +9,3 @@ /* eslint-disable no-await-in-loop */ | ||
} from '../interface'; | ||
import { DomainDoc } from '../loader'; | ||
@@ -43,2 +44,8 @@ type DocType = import('../model/document').DocType; | ||
'domain/create': (ddoc: DomainDoc) => VoidReturn | ||
'domain/before-get': (query: FilterQuery<DomainDoc>) => VoidReturn | ||
'domain/get': (ddoc: DomainDoc) => VoidReturn | ||
'domain/before-update': (domainId: string, $set: Partial<DomainDoc>) => VoidReturn | ||
'domain/update': (domainId: string, $set: Partial<DomainDoc>, ddoc: DomainDoc) => VoidReturn | ||
'document/add': (doc: any) => VoidReturn | ||
@@ -45,0 +52,0 @@ 'document/set': <T extends keyof DocType> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1728425
26049