From 3c72ab279ef5d7f573dea34f7318241cd9ceee95 Mon Sep 17 00:00:00 2001 From: tryb3l <56679619+tryb3l@users.noreply.github.com> Date: Wed, 28 Aug 2024 00:26:14 +0200 Subject: [PATCH] update readnote autohook --- routes/notes/autohooks.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/routes/notes/autohooks.js b/routes/notes/autohooks.js index 36cb28a..87ef91a 100644 --- a/routes/notes/autohooks.js +++ b/routes/notes/autohooks.js @@ -13,12 +13,19 @@ module.exports = fp( const totalCount = await notes.countDocuments(filter) return totalCount }, - async readNote(id, projection = {}) { - const note = await notes.findOne( - { _id: fastify.mongo.ObjectId.createFromTime(id) }, - { projection: { ...projection, _id: 0 } }, + async readNote(id) { + return await notes.findOne( + { _id: id }, + { + projection: { + _id: 1, + title: 1, + body: 1, + tags: 1, + createdAt: 1, + }, + }, ) - return note }, async listNotes({ filter = {},