mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: rename interface props
This commit is contained in:
1 parent
8ea50bfafb
commit
808cb5d4a5
20 files changed
+148
-154
No files matched your search
@@ -8,7 +8,7 @@ import {
|
||||
ContestNotAttendedError, ContestScoreboardHiddenError,
|
||||
} from '../error';
|
||||
import {
|
||||
ContestRule, ContestRules, Pdict,
|
||||
ContestRule, ContestRules, ProblemDict,
|
||||
ScoreboardNode, ScoreboardRow, Tdoc,
|
||||
Udict,
|
||||
} from '../interface';
|
||||
@@ -564,7 +564,7 @@ export function canShowScoreboard(tdoc: Tdoc<30 | 60>, allowPermOverride = true)
|
||||
export async function getScoreboard(
|
||||
domainId: string, tid: ObjectID,
|
||||
isExport = false, page: number, docType: 30 | 60 = document.TYPE_CONTEST,
|
||||
): Promise<[Tdoc<30 | 60>, ScoreboardRow[], Udict, Pdict, number]> {
|
||||
): Promise<[Tdoc<30 | 60>, ScoreboardRow[], Udict, ProblemDict, number]> {
|
||||
const tdoc = await get(domainId, tid, docType);
|
||||
if (!canShowScoreboard.call(this, tdoc)) throw new ContestScoreboardHiddenError(tid);
|
||||
if (!canShowRecord.call(this, tdoc)) throw new ContestScoreboardHiddenError(tid);
|
||||
|
||||
@@ -5,15 +5,15 @@ import * as contest from './contest';
|
||||
import * as training from './training';
|
||||
import * as document from './document';
|
||||
import { DiscussionNodeNotFoundError, DocumentNotFoundError } from '../error';
|
||||
import { Drdoc, Drrdoc, Document } from '../interface';
|
||||
import { DiscussionReplyDoc, DiscussionTailReplyDoc, Document } from '../interface';
|
||||
import { buildProjection } from '../utils';
|
||||
import * as bus from '../service/bus';
|
||||
|
||||
export interface Ddoc extends Document { }
|
||||
export namespace Ddoc {
|
||||
export type Field = keyof Ddoc;
|
||||
export interface DiscussionDoc extends Document { }
|
||||
export namespace DiscussionDoc {
|
||||
export type Field = keyof DiscussionDoc;
|
||||
export const fields: Field[] = [];
|
||||
type Getter = () => Partial<Ddoc>;
|
||||
type Getter = () => Partial<DiscussionDoc>;
|
||||
const getters: Getter[] = [];
|
||||
export function extend(getter: Getter) {
|
||||
getters.push(getter);
|
||||
@@ -39,7 +39,7 @@ export namespace Ddoc {
|
||||
}));
|
||||
|
||||
export function create() {
|
||||
const result = {} as Ddoc;
|
||||
const result = {} as DiscussionDoc;
|
||||
for (const getter of getters) {
|
||||
Object.assign(result, getter());
|
||||
}
|
||||
@@ -47,12 +47,12 @@ export namespace Ddoc {
|
||||
}
|
||||
}
|
||||
|
||||
export const PROJECTION_LIST: Ddoc.Field[] = [
|
||||
export const PROJECTION_LIST: DiscussionDoc.Field[] = [
|
||||
'_id', 'domainId', 'docType', 'docId', 'highlight',
|
||||
'nReply', 'views', 'pin', 'updateAt', 'owner',
|
||||
'parentId', 'parentType', 'title',
|
||||
];
|
||||
export const PROJECTION_PUBLIC: Ddoc.Field[] = [
|
||||
export const PROJECTION_PUBLIC: DiscussionDoc.Field[] = [
|
||||
...PROJECTION_LIST, 'content', 'history',
|
||||
];
|
||||
|
||||
@@ -69,7 +69,7 @@ export async function add(
|
||||
owner: number, title: string, content: string,
|
||||
ip: string | null = null, highlight: boolean, pin: boolean,
|
||||
): Promise<ObjectID> {
|
||||
const payload: Partial<Ddoc> = {
|
||||
const payload: Partial<DiscussionDoc> = {
|
||||
domainId,
|
||||
content,
|
||||
owner,
|
||||
@@ -93,15 +93,16 @@ export async function add(
|
||||
return payload.docId;
|
||||
}
|
||||
|
||||
// FIXME typings doesn't work
|
||||
export async function get<T extends Ddoc.Field>(domainId: string, did: ObjectID, projection: T[] = PROJECTION_PUBLIC as any): Promise<Pick<Ddoc, T>> {
|
||||
export async function get<T extends DiscussionDoc.Field>(
|
||||
domainId: string, did: ObjectID, projection: T[] = PROJECTION_PUBLIC as any,
|
||||
): Promise<Pick<DiscussionDoc, T>> {
|
||||
return await document.get(domainId, document.TYPE_DISCUSSION, did, projection);
|
||||
}
|
||||
|
||||
export function edit(
|
||||
domainId: string, did: ObjectID,
|
||||
title: string, content: string, highlight: boolean, pin: boolean,
|
||||
): Promise<Ddoc | null> {
|
||||
): Promise<DiscussionDoc | null> {
|
||||
const payload = {
|
||||
title, content, highlight, pin,
|
||||
};
|
||||
@@ -118,11 +119,11 @@ export function del(domainId: string, did: ObjectID): Promise<never> {
|
||||
]) as any;
|
||||
}
|
||||
|
||||
export function count(domainId: string, query: FilterQuery<Ddoc>) {
|
||||
export function count(domainId: string, query: FilterQuery<DiscussionDoc>) {
|
||||
return document.count(domainId, document.TYPE_DISCUSSION, query);
|
||||
}
|
||||
|
||||
export function getMulti(domainId: string, query: FilterQuery<Ddoc> = {}, projection = PROJECTION_LIST) {
|
||||
export function getMulti(domainId: string, query: FilterQuery<DiscussionDoc> = {}, projection = PROJECTION_LIST) {
|
||||
return document.getMulti(domainId, document.TYPE_DISCUSSION, query)
|
||||
.sort({ pin: -1, updateAt: -1 })
|
||||
.project(buildProjection(projection));
|
||||
@@ -142,13 +143,13 @@ export async function addReply(
|
||||
return drid;
|
||||
}
|
||||
|
||||
export function getReply(domainId: string, drid: ObjectID): Promise<Drdoc | null> {
|
||||
export function getReply(domainId: string, drid: ObjectID): Promise<DiscussionReplyDoc | null> {
|
||||
return document.get(domainId, document.TYPE_DISCUSSION_REPLY, drid);
|
||||
}
|
||||
|
||||
export async function editReply(
|
||||
domainId: string, drid: ObjectID, content: string,
|
||||
): Promise<Drdoc | null> {
|
||||
): Promise<DiscussionReplyDoc | null> {
|
||||
return document.set(domainId, document.TYPE_DISCUSSION_REPLY, drid, { content });
|
||||
}
|
||||
|
||||
@@ -168,14 +169,14 @@ export function getMultiReply(domainId: string, did: ObjectID) {
|
||||
).sort('_id', -1);
|
||||
}
|
||||
|
||||
export function getListReply(domainId: string, did: ObjectID): Promise<Drdoc[]> {
|
||||
export function getListReply(domainId: string, did: ObjectID): Promise<DiscussionReplyDoc[]> {
|
||||
return getMultiReply(domainId, did).toArray();
|
||||
}
|
||||
|
||||
export async function addTailReply(
|
||||
domainId: string, drid: ObjectID,
|
||||
owner: number, content: string, ip: string,
|
||||
): Promise<[Drdoc, ObjectID]> {
|
||||
): Promise<[DiscussionReplyDoc, ObjectID]> {
|
||||
const [drdoc, subId] = await document.push(
|
||||
domainId, document.TYPE_DISCUSSION_REPLY, drid,
|
||||
'reply', content, owner, { ip },
|
||||
@@ -189,14 +190,14 @@ export async function addTailReply(
|
||||
|
||||
export function getTailReply(
|
||||
domainId: string, drid: ObjectID, drrid: ObjectID,
|
||||
): Promise<[Drdoc, Drrdoc] | [null, null]> {
|
||||
): Promise<[DiscussionReplyDoc, DiscussionTailReplyDoc] | [null, null]> {
|
||||
// @ts-ignore
|
||||
return document.getSub(domainId, document.TYPE_DISCUSSION_REPLY, drid, 'reply', drrid);
|
||||
}
|
||||
|
||||
export function editTailReply(
|
||||
domainId: string, drid: ObjectID, drrid: ObjectID, content: string,
|
||||
): Promise<Drrdoc> {
|
||||
): Promise<DiscussionTailReplyDoc> {
|
||||
return document.setSub(domainId, document.TYPE_DISCUSSION_REPLY, drid, 'reply', drrid, { content });
|
||||
}
|
||||
|
||||
@@ -249,7 +250,7 @@ export function getNodes(domainId: string) {
|
||||
export async function getListVnodes(domainId: string, ddocs: any, getHidden: boolean) {
|
||||
const tasks = [];
|
||||
const res = {};
|
||||
async function task(ddoc: Ddoc) {
|
||||
async function task(ddoc: DiscussionDoc) {
|
||||
const vnode = await getVnode(domainId, ddoc.parentType, ddoc.parentId.toString());
|
||||
if (!res[ddoc.parentType]) res[ddoc.parentType] = {};
|
||||
if (vnode.hidden && !getHidden) return;
|
||||
@@ -278,7 +279,7 @@ bus.on('problem/delete', async (domainId, docId) => {
|
||||
|
||||
global.Hydro.model.discussion = {
|
||||
typeDisplay,
|
||||
Ddoc,
|
||||
DiscussionDoc,
|
||||
PROJECTION_LIST,
|
||||
PROJECTION_PUBLIC,
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
ObjectID, Cursor, FilterQuery, UpdateQuery, OnlyFieldsOfType,
|
||||
} from 'mongodb';
|
||||
import {
|
||||
Pdoc, Ddoc, Drdoc, Tdoc, TrainingDoc,
|
||||
ProblemDoc, DiscussionDoc, DiscussionReplyDoc, Tdoc, TrainingDoc,
|
||||
ProblemStatusDoc, Content,
|
||||
} from '../interface';
|
||||
import { buildProjection } from '../utils';
|
||||
@@ -28,12 +28,12 @@ export const TYPE_TRAINING: 40 = 40;
|
||||
export const TYPE_HOMEWORK: 60 = 60;
|
||||
|
||||
export interface DocType {
|
||||
[TYPE_PROBLEM]: Pdoc,
|
||||
[TYPE_PROBLEM]: ProblemDoc,
|
||||
[TYPE_PROBLEM_SOLUTION]: any,
|
||||
[TYPE_PROBLEM_LIST]: any,
|
||||
[TYPE_DISCUSSION_NODE]: any,
|
||||
[TYPE_DISCUSSION]: Ddoc,
|
||||
[TYPE_DISCUSSION_REPLY]: Drdoc,
|
||||
[TYPE_DISCUSSION]: DiscussionDoc,
|
||||
[TYPE_DISCUSSION_REPLY]: DiscussionReplyDoc,
|
||||
[TYPE_CONTEST]: Tdoc,
|
||||
[TYPE_TRAINING]: TrainingDoc,
|
||||
[TYPE_HOMEWORK]: Tdoc,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import user from './user';
|
||||
import { Mdoc } from '../interface';
|
||||
import { MessageDoc } from '../interface';
|
||||
import { ArgMethod } from '../utils';
|
||||
import db from '../service/db';
|
||||
import * as bus from '../service/bus';
|
||||
@@ -15,7 +15,7 @@ class MessageModel {
|
||||
static async send(
|
||||
from: number, to: number,
|
||||
content: string, flag: number = MessageModel.FLAG_UNREAD,
|
||||
): Promise<Mdoc> {
|
||||
): Promise<MessageDoc> {
|
||||
const res = await coll.insertOne({
|
||||
from, to, content, flag,
|
||||
});
|
||||
@@ -27,22 +27,22 @@ class MessageModel {
|
||||
return mdoc;
|
||||
}
|
||||
|
||||
static async get(_id: ObjectID): Promise<Mdoc | null> {
|
||||
static async get(_id: ObjectID): Promise<MessageDoc | null> {
|
||||
return await coll.findOne({ _id });
|
||||
}
|
||||
|
||||
@ArgMethod
|
||||
static async getByUser(uid: number): Promise<Mdoc[]> {
|
||||
static async getByUser(uid: number): Promise<MessageDoc[]> {
|
||||
return await coll.find({ $or: [{ from: uid }, { to: uid }] }).sort('_id', 1).toArray();
|
||||
}
|
||||
|
||||
static async getMany(query: FilterQuery<Mdoc>, sort: any, page: number, limit: number): Promise<Mdoc[]> {
|
||||
static async getMany(query: FilterQuery<MessageDoc>, sort: any, page: number, limit: number): Promise<MessageDoc[]> {
|
||||
return await coll.find(query).sort(sort)
|
||||
.skip((page - 1) * limit).limit(limit)
|
||||
.toArray();
|
||||
}
|
||||
|
||||
static async setFlag(messageId: ObjectID, flag: number): Promise<Mdoc | null> {
|
||||
static async setFlag(messageId: ObjectID, flag: number): Promise<MessageDoc | null> {
|
||||
const result = await coll.findOneAndUpdate(
|
||||
{ _id: messageId },
|
||||
{ $bit: { flag: { xor: flag } } },
|
||||
@@ -56,7 +56,7 @@ class MessageModel {
|
||||
}
|
||||
|
||||
@ArgMethod
|
||||
static count(query: FilterQuery<Mdoc> = {}) {
|
||||
static count(query: FilterQuery<MessageDoc> = {}) {
|
||||
return coll.find(query).count();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { streamToBuffer } from '@hydrooj/utils/lib/utils';
|
||||
import * as document from './document';
|
||||
import { STATUS } from './builtin';
|
||||
import { buildProjection } from '../utils';
|
||||
import type { ProblemStatusDoc, Pdict, Document } from '../interface';
|
||||
import type { ProblemStatusDoc, ProblemDict, Document } from '../interface';
|
||||
import {
|
||||
ArrayKeys, MaybeArray, NumberKeys, Projection,
|
||||
} from '../typeutils';
|
||||
@@ -13,10 +13,10 @@ import { ProblemNotFoundError, ValidationError } from '../error';
|
||||
import storage from '../service/storage';
|
||||
import * as bus from '../service/bus';
|
||||
|
||||
export interface Pdoc extends Document { }
|
||||
export type Field = keyof Pdoc;
|
||||
export interface ProblemDoc extends Document { }
|
||||
export type Field = keyof ProblemDoc;
|
||||
const fields: Field[] = [];
|
||||
export type Getter = (docId?: number, pid?: string) => Partial<Pdoc>;
|
||||
export type Getter = (docId?: number, pid?: string) => Partial<ProblemDoc>;
|
||||
const getters: Getter[] = [];
|
||||
|
||||
export class ProblemModel {
|
||||
@@ -37,7 +37,7 @@ export class ProblemModel {
|
||||
}
|
||||
|
||||
static create(docId?: number, pid?: string) {
|
||||
const result = {} as Pdoc;
|
||||
const result = {} as ProblemDoc;
|
||||
for (const getter of getters) {
|
||||
Object.assign(result, getter(docId, pid));
|
||||
}
|
||||
@@ -59,7 +59,7 @@ export class ProblemModel {
|
||||
domainId: string, docId: number, pid: string = null, title: string,
|
||||
content: string, owner: number, tag: string[] = [], hidden = false,
|
||||
) {
|
||||
const args: Partial<Pdoc> = {
|
||||
const args: Partial<ProblemDoc> = {
|
||||
title, tag, hidden, nSubmit: 0, nAccept: 0,
|
||||
};
|
||||
if (pid) args.pid = pid;
|
||||
@@ -74,8 +74,8 @@ export class ProblemModel {
|
||||
|
||||
static async get(
|
||||
domainId: string, pid: string | number,
|
||||
uid: number = null, projection: Projection<Pdoc> = ProblemModel.PROJECTION_PUBLIC,
|
||||
): Promise<Pdoc> {
|
||||
uid: number = null, projection: Projection<ProblemDoc> = ProblemModel.PROJECTION_PUBLIC,
|
||||
): Promise<ProblemDoc> {
|
||||
if (typeof pid !== 'number') {
|
||||
if (Number.isSafeInteger(parseInt(pid, 10))) pid = parseInt(pid, 10);
|
||||
}
|
||||
@@ -89,15 +89,15 @@ export class ProblemModel {
|
||||
return pdoc;
|
||||
}
|
||||
|
||||
static getMulti(domainId: string, query: FilterQuery<Pdoc>, projection = ProblemModel.PROJECTION_LIST) {
|
||||
static getMulti(domainId: string, query: FilterQuery<ProblemDoc>, projection = ProblemModel.PROJECTION_LIST) {
|
||||
return document.getMulti(domainId, document.TYPE_PROBLEM, query, projection);
|
||||
}
|
||||
|
||||
static getMultiStatus(domainId: string, query: FilterQuery<Pdoc>) {
|
||||
static getMultiStatus(domainId: string, query: FilterQuery<ProblemDoc>) {
|
||||
return document.getMultiStatus(domainId, document.TYPE_PROBLEM, query);
|
||||
}
|
||||
|
||||
static async edit(domainId: string, _id: number, $set: Partial<Pdoc>): Promise<Pdoc> {
|
||||
static async edit(domainId: string, _id: number, $set: Partial<ProblemDoc>): Promise<ProblemDoc> {
|
||||
const delpid = $set.pid === '';
|
||||
if (delpid) delete $set.pid;
|
||||
await bus.serial('problem/before-edit', $set);
|
||||
@@ -106,19 +106,19 @@ export class ProblemModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
static push<T extends ArrayKeys<Pdoc>>(domainId: string, _id: number, key: ArrayKeys<Pdoc>, value: Pdoc[T][0]) {
|
||||
static push<T extends ArrayKeys<ProblemDoc>>(domainId: string, _id: number, key: ArrayKeys<ProblemDoc>, value: ProblemDoc[T][0]) {
|
||||
return document.push(domainId, document.TYPE_PROBLEM, _id, key, value);
|
||||
}
|
||||
|
||||
static pull<T extends ArrayKeys<Pdoc>>(domainId: string, pid: number, key: ArrayKeys<Pdoc>, values: Pdoc[T][0][]) {
|
||||
static pull<T extends ArrayKeys<ProblemDoc>>(domainId: string, pid: number, key: ArrayKeys<ProblemDoc>, values: ProblemDoc[T][0][]) {
|
||||
return document.deleteSub(domainId, document.TYPE_PROBLEM, pid, key, values);
|
||||
}
|
||||
|
||||
static inc(domainId: string, _id: number, field: NumberKeys<Pdoc>, n: number): Promise<Pdoc> {
|
||||
static inc(domainId: string, _id: number, field: NumberKeys<ProblemDoc>, n: number): Promise<ProblemDoc> {
|
||||
return document.inc(domainId, document.TYPE_PROBLEM, _id, field, n);
|
||||
}
|
||||
|
||||
static count(domainId: string, query: FilterQuery<Pdoc>) {
|
||||
static count(domainId: string, query: FilterQuery<ProblemDoc>) {
|
||||
return document.count(domainId, document.TYPE_PROBLEM, query);
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ export class ProblemModel {
|
||||
await bus.emit('problem/delAdditionalFile', domainId, pid, names);
|
||||
}
|
||||
|
||||
static async random(domainId: string, query: FilterQuery<Pdoc>): Promise<string | null> {
|
||||
static async random(domainId: string, query: FilterQuery<ProblemDoc>): Promise<string | null> {
|
||||
const cursor = document.getMulti(domainId, document.TYPE_PROBLEM, query);
|
||||
const pcount = await cursor.count();
|
||||
if (pcount) {
|
||||
@@ -186,7 +186,7 @@ export class ProblemModel {
|
||||
static async getList(
|
||||
domainId: string, pids: Array<number | string>,
|
||||
getHidden = false, doThrow = true, projection = ProblemModel.PROJECTION_PUBLIC,
|
||||
): Promise<Pdict> {
|
||||
): Promise<ProblemDict> {
|
||||
pids = Array.from(new Set(pids)).map((i) => (+i ? +i : i));
|
||||
const r = {};
|
||||
const l = {};
|
||||
|
||||
@@ -8,15 +8,15 @@ import moment from 'moment';
|
||||
import { STATUS } from './builtin';
|
||||
import task from './task';
|
||||
import problem from './problem';
|
||||
import { Rdoc, ContestInfo, ProblemConfig } from '../interface';
|
||||
import { RecordDoc, ContestInfo, ProblemConfig } from '../interface';
|
||||
import { ArgMethod, buildProjection, Time } from '../utils';
|
||||
import { MaybeArray } from '../typeutils';
|
||||
import * as bus from '../service/bus';
|
||||
import db from '../service/db';
|
||||
|
||||
class RecordModel {
|
||||
static coll: Collection<Rdoc> = db.collection('record');
|
||||
static PROJECTION_LIST: (keyof Rdoc)[] = [
|
||||
static coll: Collection<RecordDoc> = db.collection('record');
|
||||
static PROJECTION_LIST: (keyof RecordDoc)[] = [
|
||||
'_id', 'score', 'time', 'memory', 'lang',
|
||||
'uid', 'pid', 'rejudged', 'hidden', 'progress',
|
||||
'contest', 'effective', 'judger', 'judgeAt', 'status',
|
||||
@@ -29,7 +29,7 @@ class RecordModel {
|
||||
return base - ((pending + 0.5) * (sum(timeRecent.map((i) => i.time || 0)) / 10000));
|
||||
}
|
||||
|
||||
static async get(domainId: string, _id: ObjectID): Promise<Rdoc | null> {
|
||||
static async get(domainId: string, _id: ObjectID): Promise<RecordDoc | null> {
|
||||
const res = await RecordModel.coll.findOne({ _id });
|
||||
if (res && res.domainId === domainId) return res;
|
||||
return null;
|
||||
@@ -74,7 +74,7 @@ class RecordModel {
|
||||
domainId: string, pid: number, uid: number,
|
||||
lang: string, code: string, addTask: boolean, contestOrConfig?: ContestInfo | string,
|
||||
) {
|
||||
const data: Rdoc = {
|
||||
const data: RecordDoc = {
|
||||
status: STATUS.STATUS_WAITING,
|
||||
_id: new ObjectID(),
|
||||
uid,
|
||||
@@ -116,11 +116,11 @@ class RecordModel {
|
||||
|
||||
static async update(
|
||||
domainId: string, _id: MaybeArray<ObjectID>,
|
||||
$set?: MatchKeysAndValues<Rdoc>,
|
||||
$push?: PushOperator<Rdoc>,
|
||||
$unset?: OnlyFieldsOfType<Rdoc, any, true | '' | 1>,
|
||||
): Promise<Rdoc | null> {
|
||||
const $update: UpdateQuery<Rdoc> = {};
|
||||
$set?: MatchKeysAndValues<RecordDoc>,
|
||||
$push?: PushOperator<RecordDoc>,
|
||||
$unset?: OnlyFieldsOfType<RecordDoc, any, true | '' | 1>,
|
||||
): Promise<RecordDoc | null> {
|
||||
const $update: UpdateQuery<RecordDoc> = {};
|
||||
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;
|
||||
@@ -140,12 +140,12 @@ class RecordModel {
|
||||
}
|
||||
|
||||
static async updateMulti(
|
||||
domainId: string, $match: FilterQuery<Rdoc>,
|
||||
$set?: MatchKeysAndValues<Rdoc>,
|
||||
$push?: PushOperator<Rdoc>,
|
||||
$unset?: OnlyFieldsOfType<Rdoc, any, true | '' | 1>,
|
||||
domainId: string, $match: FilterQuery<RecordDoc>,
|
||||
$set?: MatchKeysAndValues<RecordDoc>,
|
||||
$push?: PushOperator<RecordDoc>,
|
||||
$unset?: OnlyFieldsOfType<RecordDoc, any, true | '' | 1>,
|
||||
) {
|
||||
const $update: UpdateQuery<Rdoc> = {};
|
||||
const $update: UpdateQuery<RecordDoc> = {};
|
||||
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;
|
||||
@@ -174,8 +174,8 @@ class RecordModel {
|
||||
}
|
||||
|
||||
static async getList(
|
||||
domainId: string, rids: ObjectID[], showHidden: boolean, fields?: (keyof Rdoc)[],
|
||||
): Promise<Record<string, Partial<Rdoc>>> {
|
||||
domainId: string, rids: ObjectID[], showHidden: boolean, fields?: (keyof RecordDoc)[],
|
||||
): Promise<Record<string, Partial<RecordDoc>>> {
|
||||
const r = {};
|
||||
rids = Array.from(new Set(rids));
|
||||
let cursor = RecordModel.coll.find({ domainId, _id: { $in: rids } });
|
||||
@@ -202,7 +202,7 @@ class RecordModel {
|
||||
}
|
||||
|
||||
@ArgMethod
|
||||
static getByUid(domainId: string, uid: number, limit: number): Promise<Rdoc[]> {
|
||||
static getByUid(domainId: string, uid: number, limit: number): Promise<RecordDoc[]> {
|
||||
return RecordModel.coll.find({ domainId, uid, hidden: false }).sort({ _id: -1 }).limit(limit).toArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user