Skip to content

Commit 21caab9

Browse files
authored
Note @foreignkey can be applied multiple times (#274)
1 parent 6c6f323 commit 21caab9

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/pages/postgraphile/smart-tags.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ comment on view my_view is E'@primaryKey type,identifier';
586586

587587
##### @foreignKey
588588

589-
The foreign key adds a virtual constraint pretending to be a foreign key. It has
589+
The foreign key adds virtual constraints pretending to be foreign keys. It has
590590
the following syntax which mirrors the PostgreSQL foreign key constraint:
591591

592592
`@foreignKey (col1, ...) references [my_schema.]my_table [(col1, ...)]`
@@ -615,10 +615,26 @@ class: {
615615
}
616616
}
617617
}
618+
619+
// or if you want multiple foreignKeys
620+
class: {
621+
my_materialized_view: {
622+
tags: {
623+
foreignKey: [
624+
"(key_1, key_2) references other_table (key_1, key_2)",
625+
"(key_3, key_4) references some_other_table (key_3, key_4)"
626+
]
627+
}
628+
}
629+
}
630+
618631
```
619632
620633
```sql
621634
comment on materialized view my_materialized_view is E'@foreignKey (key_1, key_2) references other_table (key_1, key_2)';
635+
636+
-- or if you want multiple foreignKeys
637+
comment on materialized view my_materialized_view is E'@foreignKey (key_1, key_2) references other_table (key_1, key_2)\n@foreignKey (key_3, key_4) references some_other_table (key_3, key_4)';
622638
```
623639
624640
##### @unique

0 commit comments

Comments
 (0)