From e06c76cb567dba02771e958b0647d5c143f3004f Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 20 May 2022 22:40:42 +0800 Subject: [PATCH] fix: note update lean --- src/modules/note/note.service.ts | 47 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/modules/note/note.service.ts b/src/modules/note/note.service.ts index fd5f4790..1b451581 100644 --- a/src/modules/note/note.service.ts +++ b/src/modules/note/note.service.ts @@ -147,29 +147,32 @@ export class NoteService { }) await Promise.all([ this.imageService.recordImageDimensions(this.noteModel, id), - this.model.findById(id).then(async (doc) => { - if (!doc) { - return - } - delete doc.password - this.eventManager.broadcast(BusinessEvents.NOTE_UPDATE, doc, { - scope: EventScope.TO_SYSTEM, - }) + this.model + .findById(id) + .lean() + .then(async (doc) => { + if (!doc) { + return + } + delete doc.password + this.eventManager.broadcast(BusinessEvents.NOTE_UPDATE, doc, { + scope: EventScope.TO_SYSTEM, + }) - this.eventManager.broadcast( - BusinessEvents.NOTE_UPDATE, - { - ...doc, - text: await this.textMacrosService.replaceTextMacro( - doc.text, - doc, - ), - }, - { - scope: EventScope.TO_VISITOR, - }, - ) - }), + this.eventManager.broadcast( + BusinessEvents.NOTE_UPDATE, + { + ...doc, + text: await this.textMacrosService.replaceTextMacro( + doc.text, + doc, + ), + }, + { + scope: EventScope.TO_VISITOR, + }, + ) + }), ]) }) return updated