fix: remove designated refType

This commit is contained in:
Innei
2022-06-18 18:28:59 +08:00
parent 18ec4f1370
commit b046eee9e4
2 changed files with 4 additions and 18 deletions

View File

@@ -1,10 +1,4 @@
import {
IsEnum,
IsMongoId,
IsOptional,
IsString,
ValidateIf,
} from 'class-validator'
import { IsMongoId, IsOptional, IsString } from 'class-validator'
import { modelOptions, prop } from '@typegoose/typegoose'
@@ -48,9 +42,7 @@ export class RecentlyModel extends BaseModel {
ref: RefType
@prop({ enum: CommentRefTypes })
@IsEnum(CommentRefTypes)
@ValidateIf((model) => model.ref)
refType: CommentRefTypes
refType: string
get refId() {
return (this.ref as any)?._id ?? this.ref
@@ -58,13 +50,5 @@ export class RecentlyModel extends BaseModel {
set refId(id: string) {
return
// if (!id) {
// return
// }
// if (this.ref) {
// ;(this.ref as any)._id = id
// } else {
// this.ref = id as any
// }
}
}

View File

@@ -84,6 +84,8 @@ export class RecentlyService {
if (!existModel.type) {
throw new BadRequestException('ref model not found')
}
model.refType = existModel.type
}
const res = await this.model.create({