From 5549c8c8043ab06d98a36f4445b486bfd4a72e78 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 27 Apr 2021 17:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=80=E4=BA=9B=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.server.ts | 2 +- src/decorators/nojson.ts | 1 - src/models/Account.ts | 3 +-- src/models/AppInfo.ts | 13 ++++--------- src/models/match/PuzzleSession.ts | 5 +++++ 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/api.server.ts b/src/api.server.ts index 81d6cfb..ab0c451 100644 --- a/src/api.server.ts +++ b/src/api.server.ts @@ -73,7 +73,7 @@ export class ApiServer { fs.readdirSync(controllers) .filter((file: string) => ~file.search(/^[^.].*\.(ts|js)$/)) .forEach((file: any) => { - logger.log(file); + // logger.log(file); return require(join(controllers, file))}); } async connectDB() { diff --git a/src/decorators/nojson.ts b/src/decorators/nojson.ts index e4c5518..65d1d86 100644 --- a/src/decorators/nojson.ts +++ b/src/decorators/nojson.ts @@ -22,7 +22,6 @@ export class NoJsonClass { export function noJson() { // return Reflect.metadata(noJsonMetadataKey, !0) return function(target: Object, propertyKey: string) { - console.log(target) new NoJsonClass().addKey(target.constructor.name, propertyKey) } } diff --git a/src/models/Account.ts b/src/models/Account.ts index 4ce4b76..acef4ae 100644 --- a/src/models/Account.ts +++ b/src/models/Account.ts @@ -1,5 +1,4 @@ import { - arrayProp, getModelForClass, index, modelOptions, @@ -52,7 +51,7 @@ class AccountClass extends BaseModule{ public lockedTime?: Date; @prop() public comment?: string; - @arrayProp({ items: String }) + @prop({ type: () => [String], default: [] }) public friends: string[]; @prop() public lastLogin?: Date; diff --git a/src/models/AppInfo.ts b/src/models/AppInfo.ts index 2fa786f..640d388 100644 --- a/src/models/AppInfo.ts +++ b/src/models/AppInfo.ts @@ -1,11 +1,6 @@ -import { - arrayProp, - getModelForClass, - modelOptions, - prop -} from '@typegoose/typegoose'; -import {dbconn} from '../decorators/dbconn'; -import {Base, TimeStamps} from "@typegoose/typegoose/lib/defaultClasses"; +import { getModelForClass, modelOptions, prop } from '@typegoose/typegoose' +import { dbconn } from '../decorators/dbconn' +import { Base, TimeStamps } from '@typegoose/typegoose/lib/defaultClasses' @modelOptions({schemaOptions: {_id: false}}) export class PlatInfo { @@ -38,7 +33,7 @@ class AppClass extends Base{ public name: string; @prop() public icon: string; - @arrayProp({ items: PlatInfo }) + @prop({ type: () => [PlatInfo], default: [] }) public plats?: PlatInfo[]; @prop() public comment?: string; diff --git a/src/models/match/PuzzleSession.ts b/src/models/match/PuzzleSession.ts index b4ca3c5..d676cd9 100644 --- a/src/models/match/PuzzleSession.ts +++ b/src/models/match/PuzzleSession.ts @@ -1,6 +1,11 @@ import { dbconn } from '../../decorators/dbconn' import { getModelForClass, modelOptions, prop } from '@typegoose/typegoose' import { BaseModule } from '../Base' +import { Severity } from '@typegoose/typegoose/lib/internal/constants' + +@modelOptions({ + options: {allowMixed: Severity.ALLOW} +}) export class PuzzleStatusClass { @prop({default: []})