Skip to content

Commit

Permalink
update readnote autohook
Browse files Browse the repository at this point in the history
  • Loading branch information
tryb3l committed Aug 27, 2024
1 parent 83a5431 commit 3c72ab2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions routes/notes/autohooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {},
Expand Down

0 comments on commit 3c72ab2

Please sign in to comment.