Like what we’re doing? Star us on GitHub!

How to add composite unique condition

rednithin
2 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',
},
  • JarrodMFlesch
    Payload Team
    2 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
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More