Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Petrol.SchemaSourceProvides an E-DSL for specifying SQL tables in OCaml.
'a constraint_ represents a constraint on an SQL column or columns.
'a field represents an SQL table field definition.
field ?constraints name ~ty constructs a new table column with name name and type ty.
constraints are a list of column constraints for the column.
Note name must be a valid SQL identifier - this is not checked by the function, but will cause an SQL error at runtime.
'a table represents a heterogeneous list of fields in a SQL Table schema, where 'a captures the types of each element.
Like Expr.expr_list, if you have opened the Schema module, you can use vanilla list syntax to construct terms of this type.
val primary_key :
?name:string ->
?ordering:[ `ASC | `DESC ] ->
?on_conflict:conflict_clause ->
?auto_increment:bool ->
unit ->
[ `Column ] constraint_primary_key ?name ?ordering ?on_conflict ?auto_increment () returns a new SQL column constraint that indicates that the column it is attached to must be the primary key.
name is an optional name for the constraint for debugging purposes.
ordering is the ordering of the primary key index.
on_conflict specifies how to handle conflicts.
auto_increment specifies whether the primary key should be automatically generated. (Note: not supported for Postgres databases.)
val table_primary_key :
?name:string ->
?on_conflict:conflict_clause ->
string list ->
[ `Table ] constraint_table_primary_key ?name ?on_conflict cols returns a new SQL table constraint that specifies that the table it is attached to's primary key is over the columns in cols.
name is an optional name for the constraint for debugging purposes.
on_conflict specifies how to handle conflicts.
val not_null :
?name:string ->
?on_conflict:conflict_clause ->
unit ->
[ `Column ] constraint_not_null ?name ?on_conflict () returns a new SQL column constraint that specifies that the column it is attached to's value must not be NULL.
name is an optional name for the constraint for debugging purposes.
on_conflict specifies how to handle conflicts.
unique ?name ?on_conflict () returns a new SQL column constraint that specifies that the column it is attached to's values must be unique.
name is an optional name for the constraint for debugging purposes.
on_conflict specifies how to handle conflicts.
val table_unique :
?name:string ->
?on_conflict:conflict_clause ->
string list ->
[ `Table ] constraint_unique ?name ?on_conflict cols returns a new SQL table constraint that specifies that the table it is attached to's values for the columns cols must be unique.
name is an optional name for the constraint for debugging purposes.
on_conflict specifies how to handle conflicts.
val foreign_key :
?name:string ->
?on_update:foreign_conflict_clause ->
?on_delete:foreign_conflict_clause ->
table:table_name ->
columns:'a Expr.expr_list ->
unit ->
[ `Column ] constraint_foreign_key ?name ?on_update ?on_delete ~table ~columns () returns a new SQL column constraint that specifies that the column it is attached to's values must be a foreign key into the table table with columns columns.
name is an optional name for the constraint for debugging purposes.
on_update and on_delete specifies how to handle conflicts for updates and deletes respectively.
val table_foreign_key :
?name:string ->
?on_update:foreign_conflict_clause ->
?on_delete:foreign_conflict_clause ->
table:table_name ->
columns:'a Expr.expr_list ->
string list ->
[ `Table ] constraint_table_foreign_key ?name ?on_update ?on_delete ~table ~columns cols returns a new SQL table constraint that specifies that the table it is attached to's values for the columns cols must be a foreign key into the table table with columns columns.
name is an optional name for the constraint for debugging purposes.
on_update and on_delete specifies how to handle conflicts for updates and deletes respectively..