I have a collection Properties that hasMany Reviews.
Each Review hasOne Property
How can I get the reviews to show on the Property collection page?
// Properties
//...
fields: [
//...
{
name: 'reviews',
type: 'relationship',
relationTo: 'ratings',
hasMany: true,
}
]
//...
And my Ratings collection:
import { CollectionConfig } from 'payload/types'
const Ratings: CollectionConfig = {
slug: 'ratings',
access: {
read: () => true,
},
admin: {
useAsTitle: 'name',
},
fields: [
{
name: 'name',
label: 'Customer Name',
type: 'text',
},
{
name: 'email',
type: 'text',
},
{
name: 'rating',
type: 'number',
},
{
name: 'review',
type: 'textarea',
},
{
name: 'property',
type: 'relationship',
relationTo: 'properties',
hasMany: false,
}
],
}
export default Ratings
I think I need to use filterOptions but I'm not sure how to write a query for that. Also, I don't want the user to select the reviews individually on the Property collection page. I want them to show up there when a new review is created and associated to the Property
Any help would be greatly appreciated
Sincerely,
Lost Frontend Dev