({ id: _id })
| 21 | })) |
| 22 | } |
| 23 | async function findById ({ id: _id }) { |
| 24 | const db = await makeDb() |
| 25 | const result = await db.collection('comments').find({ _id }) |
| 26 | const found = await result.toArray() |
| 27 | if (found.length === 0) { |
| 28 | return null |
| 29 | } |
| 30 | const { _id: id, ...info } = found[0] |
| 31 | return { id, ...info } |
| 32 | } |
| 33 | async function findByPostId ({ postId, omitReplies = true }) { |
| 34 | const db = await makeDb() |
| 35 | const query = { postId: postId } |