How to add composite unique condition

default discord avatar
8 months ago
1 1

How can I add a composite unique condition on two fields (author, slug)

  name: 'slug',
  type: 'text',
  name: 'author',
  type: 'relationship',
  relationTo: 'creators',
  • discord user avatar
    Payload Team
    8 months ago

    @rednithin you could make a third field that concatenates these two (with a hook), and mark that field as unique.

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.