How do you define a unique index in EdgeDB?
For simple properties you can add constraint exclusive
which implicitly creates a unique index.
required property name -> str {
constraint exclusive;
}
However you can't add constraint exclusive
to an explicitly defined index. How do you mark such an index as unique?
You can add
constraint exclusive on (...)
to the containing type, where...
is an arbitrary scalar expression. To ensure the uniqueness of multiple properties, it should be a tuple(x, y)
:An exclusive constraint implicitly creates an index.
source