Compound indexes

default discord avatar
ysione
11 months ago
2

Is there a way to describe compound index for collection?



Use case:


Collection has two fields

title

and

value

Collection should have only unique pairs of title and value


Like:


title | value


------------|--------------


email | google


------------|--------------


email | yahoo

  • discord user avatar
    denolfe
    Payload Team
    11 months ago

    Not out of the box currently. An option would be to make an additional field that is readOnly, then write a beforeValidate hook that populates it with the 2 values concatenated.

  • default discord avatar
    ysione
    11 months ago

    I see, thank you

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

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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