@@ -74,7 +74,7 @@ export class CommentController {
|
||||
@IsMaster() isMaster: boolean,
|
||||
) {
|
||||
const { id } = params
|
||||
const data: CommentModel = await this.commentService.model
|
||||
const data: CommentModel | null = await this.commentService.model
|
||||
.findOne({
|
||||
_id: id,
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LeanDocument, Types } from 'mongoose'
|
||||
import { Types } from 'mongoose'
|
||||
import { URL } from 'url'
|
||||
|
||||
import {
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
forwardRef,
|
||||
} from '@nestjs/common'
|
||||
import { DocumentType } from '@typegoose/typegoose'
|
||||
import { BeAnObject, ReturnModelType } from '@typegoose/typegoose/lib/types'
|
||||
import { ReturnModelType } from '@typegoose/typegoose/lib/types'
|
||||
|
||||
import { BusinessException } from '~/common/exceptions/biz.exception'
|
||||
import { CannotFindException } from '~/common/exceptions/cant-find.exception'
|
||||
@@ -121,7 +121,7 @@ export class CommentService {
|
||||
doc: Partial<CommentModel>,
|
||||
type?: CommentRefTypes,
|
||||
) {
|
||||
let ref: LeanDocument<DocumentType<WriteBaseModel, BeAnObject>>
|
||||
let ref: (WriteBaseModel & { _id: any }) | null = null
|
||||
if (type) {
|
||||
const model = this.getModelByRefType(type)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { ClassConstructor, plainToInstance } from 'class-transformer'
|
||||
import { ValidatorOptions, validateSync } from 'class-validator'
|
||||
import cluster from 'cluster'
|
||||
import { cloneDeep, mergeWith } from 'lodash'
|
||||
import { LeanDocument } from 'mongoose'
|
||||
|
||||
import {
|
||||
BadRequestException,
|
||||
@@ -11,8 +10,7 @@ import {
|
||||
Logger,
|
||||
ValidationPipe,
|
||||
} from '@nestjs/common'
|
||||
import { DocumentType, ReturnModelType } from '@typegoose/typegoose'
|
||||
import { BeAnObject } from '@typegoose/typegoose/lib/types'
|
||||
import { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
import { EventScope } from '~/constants/business-event.constant'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
@@ -263,8 +261,8 @@ export class ConfigsService {
|
||||
|
||||
get getMaster() {
|
||||
// HINT: 需要注入 this 的指向
|
||||
return this.userService.getMaster.bind(this.userService) as () => Promise<
|
||||
LeanDocument<DocumentType<UserModel, BeAnObject>>
|
||||
>
|
||||
return this.userService.getMaster.bind(
|
||||
this.userService,
|
||||
) as () => Promise<UserModel>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export class LinkService {
|
||||
})
|
||||
.lean()
|
||||
|
||||
let nextModel: LinkModel
|
||||
let nextModel: LinkModel | null
|
||||
if (existedDoc) {
|
||||
switch (existedDoc.state) {
|
||||
case LinkState.Pass:
|
||||
|
||||
@@ -227,7 +227,7 @@ export class NoteController {
|
||||
const { nid } = params
|
||||
const { password, single: isSingle } = query
|
||||
const condition = isMaster ? {} : { hide: false }
|
||||
const current: NoteModel = await this.noteService.model
|
||||
const current: NoteModel | null = await this.noteService.model
|
||||
.findOne({
|
||||
nid,
|
||||
...condition,
|
||||
|
||||
@@ -57,7 +57,7 @@ export class NoteService {
|
||||
condition: FilterQuery<DocumentType<NoteModel>> = {},
|
||||
projection: any = undefined,
|
||||
) {
|
||||
const latest: NoteModel = await this.noteModel
|
||||
const latest: NoteModel | null = await this.noteModel
|
||||
.findOne(condition, projection)
|
||||
.sort({
|
||||
created: -1,
|
||||
|
||||
Reference in New Issue
Block a user