mirror of
https://github.com/wassname/talk.git
synced 2026-08-20 12:50:41 +08:00
24 lines
693 B
JavaScript
24 lines
693 B
JavaScript
const express = require('express');
|
|
|
|
const Comment = require('../../../models/comment');
|
|
const User = require('../../../models/user');
|
|
const Action = require('../../../models/action');
|
|
|
|
const router = express.Router();
|
|
|
|
router.get('/', (req, res, next) => {
|
|
|
|
const comments = Comment.findByAssetId(req.query.asset_id);
|
|
const users = User.findByIdArray(comments.map((comment) => comment.author_id));
|
|
const actions = Action.findByItemIdArray(comments.map((comment) => comment.id));
|
|
|
|
Promise.all([comments, users, actions]).then(([comments, users, actions]) => {
|
|
res.json([...comments,...users,...actions]);
|
|
}).catch(error => {
|
|
next(error);
|
|
});
|
|
|
|
});
|
|
|
|
module.exports = router;
|