(momentId)
| 28 | } |
| 29 | |
| 30 | async getCommentsByMomentId(momentId) { |
| 31 | const statement = ` |
| 32 | SELECT |
| 33 | m.id, m.content, m.comment_id commendId, m.createAt createTime, |
| 34 | JSON_OBJECT('id', u.id, 'name', u.name) user |
| 35 | FROM comment m |
| 36 | LEFT JOIN user u ON u.id = m.user_id |
| 37 | WHERE moment_id = ?; |
| 38 | `; |
| 39 | const [result] = await connection.execute(statement, [momentId]); |
| 40 | return result; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | module.exports = new CommentService(); |