我有3个文件:控制器、服务和dao。我想做函数readPost,但当使用postman时,它似乎卡在postDao内部的createPost函数中。请帮助我。
数据访问对象
const createPost = async (user_id, contents, posting_id, image_url) => {
await myDataSource.query(
`INSERT INTO postings ( user_id, contents )
VALUE (?, ?)`,
[user_id, contents]
),
const post = await myDataSource.query(
`INSERT INTO posting_images ( posting_id, image_url )
VALUE (?, ?)`,
[posting_id, image_url]
);
return post;
};
const readPost = async () => {
const postings = await myDataSource.query(
`SELECT
p.user_id, u.profile_image,
p_i.posting_id, p_i.image_url, p.contents
FROM users u
JOIN postings p
ON u.id = p.user_id
JOIN posting_images p_i
ON p.id = p_i.posting_id`
);
return postings;
};
module.exports = { createPost, readPost };
1条答案
按热度按时间csga3l581#
你能这样试试吗?
参考mySQL insert