MCPcopy Create free account
hub / github.com/coderwhy/coderhub / getMomentList

Method getMomentList

src/service/moment.service.js:47–63  ·  view source on GitHub ↗
(offset, size)

Source from the content-addressed store, hash-verified

45 }
46
47 async getMomentList(offset, size) {
48 const statement = `
49 SELECT
50 m.id id, m.content content, m.createAt createTime, m.updateAt updateTime,
51 JSON_OBJECT('id', u.id, 'name', u.name) author,
52 (SELECT COUNT(*) FROM comment c WHERE c.moment_id = m.id) commentCount,
53 (SELECT COUNT(*) FROM moment_label ml WHERE ml.moment_id = m.id) labelCount,
54 (SELECT JSON_ARRAYAGG(CONCAT('http://localhost:8000/moment/images/', file.filename))
55 FROM file WHERE m.id = file.moment_id) images
56 FROM moment m
57 LEFT JOIN user u ON m.user_id = u.id
58 LIMIT ?, ?;
59 `;
60
61 const [result] = await connection.execute(statement, [offset, size]);
62 return result;
63 }
64
65 async update(content, momentId) {
66 const statement = `UPDATE moment SET content = ? WHERE id = ?;`;

Callers 1

listMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected