How to configure a multi columns constrain

#1

How can we define a multi columns contrain in the type system, ie the equivalent of:
CREATE TABLE example (
a integer,
b integer,
UNIQUE (a, c)
);

0 Likes

#2

You can add a unique constraint on a set of fields using the @db(unique=[…]) annotation. The array takes a list of unique indexes to be created for the type. Each index is a comma separated list of fields. For example,

@db(unique=[‘a,c’])
entity type MyType schema name ‘MYTYPE’ {
a : string
c: string
}

0 Likes