Skip to content
Discussion options

You must be logged in to vote

I'd approach it this way:

  • A beforeChange hook on RatingCollection to save the user who is rating in a readonly or disabled field
  • An access:read function to show the user only his own ratings
  • A validate function on the product relation to check the uniqueness of the [user, products] rating

Something like this:

const ProductsCollection: CollectionConfig = {
  slug: 'products-for-rating',
  labels: { plural: 'Products' },
  admin: {
    group: 'Rating',
    useAsTitle: 'productName'
  },
  fields: [
    {
      name: 'productName',
      type: 'text',
    }
  ],
}
const RatingsCollection: CollectionConfig = {
  slug: 'ratings',
  admin: {
    group: 'Rating',
  },
  fields: [
    {
      name

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zubricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants