Crud для связанных таблиц
Есть две таблицы User и Post, я пытаюсь получить именно те посты, которые относятся к юзеру, но не могу понять как достать их из Posts
async function postFromUser(id,post_id){
let myPost = {};
let user = await User.findByPk(id,{
include:[Post],
require:true,
})
if (user === null){
console.log("user not found");
}
for(let obj of user.Posts){
myPost=obj
}
let res= await Post.findAll({myPost, where:{id:post_id}})
return res
}
app. get('/user/:id/posts/:post_id',(request,response)=>{
postFromUser(request.params.id,request.params.post_id).then(res=>response.send(res))
})