{
path: "/me",
method: "get",
handler: async (req, res, next) => {
if (!req?.user?.id) {
return res.status(404).send({ error: "user not found" });
}
console.log(req.user.id)
const query = {
"owner.id": req.user.id,
};
const data = await payload.find({
depth : 2,
collection: "thoughts",
where : {
"owner.id": req.user.id,
}
});
if (data) {
console.log(data)
res.status(200).send( data );
} else {
res.status(404).send({ error: "not found" });
}
},
},
#Custom query not filtering data
5 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
Community-Help:
- [The following path cannot be queried: status","data":[{"path":"status"}]}]](https://payloadcms.com/community-help/discord/the-following-path-cannot-be-queried-status-data-path-status)
Hey @winter chasm! Try adjusting your query to the following:
const data = await payload.find({
depth : 2,
collection: "thoughts",
where : {
owner: {
equals: req.user.id
}
}
});
Here is the section in the docs that talks about querying: https://payloadcms.com/docs/queries/overview
Thanks, I figured it out late last night after trial and error, and I did read this documentation but there is no specific example on relationships. I was checking against owner.id and not owner 🙏🏾
I like what I see with payload, a little worried about running into things like this when working on a client project… trying to come up with all with a robust example project to get all of the questions answered so we are not blocked when we are on the clock. Thanks for your help @sinful sand