Persist — Persistence Primitives

Part of the std module. Available via import std.

Persistence primitives for SQL database backends. Provides typed foreign key references (Persistent-style Key types) and SQL-specific types.

Types

Key

wrap Key a : Integer

A typed foreign key reference. The type parameter indicates which entity this key references. For example, Key User is a foreign key pointing to the User table. Validation is enforced at the database level (PRIMARY KEY implies > 0).

Entity

type Entity a
  key: Key a
  value: a

A persisted value paired with its database key.

SQLDefault

union SQLDefault
  none
  autoIncrement
  currentTime
  value: Text

SQL column default value specification.

IndexType

union IndexType
  primary
  unique
  indexed
  none

Index specification for columns.

ForeignKeyAction

union ForeignKeyAction
  cascade
  restrict
  setNull
  setDefault
  noAction

On delete/update foreign key action.

Interface

entity

interface entity: a. Boolean
  x. y. x && y

Marker interface for types that can be persisted to SQL tables. Multiple entity predicates are combined with logical AND.