({ commentId, publishedOnly = true })
| 43 | })) |
| 44 | } |
| 45 | async function findReplies ({ commentId, publishedOnly = true }) { |
| 46 | const db = await makeDb() |
| 47 | const query = publishedOnly |
| 48 | ? { published: true, replyToId: commentId } |
| 49 | : { replyToId: commentId } |
| 50 | const result = await db.collection('comments').find(query) |
| 51 | return (await result.toArray()).map(({ _id: id, ...found }) => ({ |
| 52 | id, |
| 53 | ...found |
| 54 | })) |
| 55 | } |
| 56 | async function insert ({ id: _id = Id.makeId(), ...commentInfo }) { |
| 57 | const db = await makeDb() |
| 58 | const result = await db |