Repodb.Field

repodb · API reference

type ('record, 'value) t = {
  name : string;
  ty : 'value Types.t;
  get : 'record -> 'value;
  set : 'value -> 'record -> 'record;
  table_name : string;
  primary_key : bool;
  unique : bool;
  nullable : bool;
  default : string option;
}

('record, 'value) t represents a field of type 'value in 'record.

val make : 
  ?primary_key:bool ->
  ?unique:bool ->
  ?default:string option ->
  table_name:string ->
  name:string ->
  ty:'a Types.t ->
  get:('b -> 'a) ->
  set:('a -> 'b -> 'b) ->
  unit ->
  ('b, 'a) t
val name : ('a, 'b) t -> string
val field_type : ('a, 'b) t -> 'b Types.t
val qualified_name : ('a, 'b) t -> string
val get : ('a, 'b) t -> 'a -> 'b
val set : ('a, 'b) t -> 'b -> 'a -> 'a
val is_primary_key : ('a, 'b) t -> bool
val is_unique : ('a, 'b) t -> bool
val is_nullable : ('a, 'b) t -> bool
type 'record field_list = 
  | [] : 'record field_list
  | :: : ('record, 'a) t * 'record field_list -> 'record field_list
val field_names : 'r. 'r field_list -> string list