I have a field relationTo inside my collection that has hasMany. I'm trying to create a fetch query that can find a value inside of that field. How can I do that? Thanks
is relationTo and array or a string?
It a news tags, this is the sample news return
{
newsTitle: "Hello",
....
tags: [
{
value: {
title: "Tag name",
....
}
relationTo: "tags"
},
{
....
}
]
}
I want to query tags item title if its the same with "Tag name"
@johnmadrigal_ to clarify - you want to query your news collection and return documents based on the tags?
That would look something like this:
const posts = await payload.find({
collection: 'posts',
where: {
'tags.name': {
contains: 'Test', // Your tagname here
},
},
});
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.