Skip to content

Commit f054fe5

Browse files
committed
refactor(markdown): optimize article extraction with Promise.all
- Refactored the extractAllArticle method to utilize Promise.all for concurrent fetching of posts, notes, and pages, improving performance and code readability. - Simplified the return structure by directly assigning the results of the Promise.all call. Signed-off-by: Innei <tukon479@gmail.com>
1 parent e80b776 commit f054fe5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

apps/core/src/modules/markdown/markdown.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,15 @@ export class MarkdownService {
155155
}
156156

157157
async extractAllArticle() {
158+
const [posts, notes, pages] = await Promise.all([
159+
this.postModel.find().populate('category').lean(),
160+
this.noteModel.find().lean(),
161+
this.pageModel.find().lean(),
162+
])
158163
return {
159-
posts: await this.postModel.find().populate('category').lean(),
160-
notes: await this.noteModel.find().lean(),
161-
pages: await this.pageModel.find().lean(),
164+
posts,
165+
notes,
166+
pages,
162167
}
163168
}
164169

0 commit comments

Comments
 (0)