({ id: _id, ...commentInfo })
| 63 | } |
| 64 | |
| 65 | async function update ({ id: _id, ...commentInfo }) { |
| 66 | const db = await makeDb() |
| 67 | const result = await db |
| 68 | .collection('comments') |
| 69 | .updateOne({ _id }, { $set: { ...commentInfo } }) |
| 70 | return result.modifiedCount > 0 ? { id: _id, ...commentInfo } : null |
| 71 | } |
| 72 | async function remove ({ id: _id }) { |
| 73 | const db = await makeDb() |
| 74 | const result = await db.collection('comments').deleteOne({ _id }) |