{
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" });
}
},
},
Hey @aaronksaunders! 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/overviewThanks, 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 @jarrod_not_jared
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.