I’m having a problem with the find() method. I’m trying to filter all the posts by the user’s id, but instead of returning only the posts from a user with the same id, it returns two. Here’s the code:
async find(ctx) {
const user = ctx.state.user;
ctx.query.filters = {
...(ctx.query.filters || {}),
owner: user.id,
};
return super.find(ctx);
},
The response:
"data": [
{
"id": 1,
"attributes": {
"createdAt": "2023-07-25T18:05:55.769Z",
"updatedAt": "2023-07-25T18:07:33.271Z",
"publishedAt": "2023-07-25T18:07:33.268Z",
"title": "Matheus: Teste",
"content": "<p>Matheus: dá certo pelo amor de Deus</p>"
}
},
{
"id": 2,
"attributes": {
"createdAt": "2023-07-25T18:06:15.014Z",
"updatedAt": "2023-07-25T18:07:36.472Z",
"publishedAt": "2023-07-25T18:07:36.470Z",
"title": "Mozart: 1",
"content": "<p>Mozart: 1 -- Teste</p>"
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 2
}
}
}