Database.Sequence

Database

Database sequences for monotonic primary keys and similar identifiers. Declare them in a database module alongside tables; allocate with next inside a Transaction.

Types

Sequence

type Sequence a = Sequence

A named sequence that yields values of type a.

Examples

todoIDs : Sequence TodoID
todoIDs :=
    Seq.uint64 TodoID

Values

next

next : Sequence a -> Transaction a

Allocate the next value from a sequence.

Examples

Seq.next todoIDs
    |> andThen
        (\id ->
            insert todos user { id = id, owner = user, title = title, completed = False }
        )

uint8

uint8 : (UInt8 -> a) -> Description (Sequence a)

Declare an 8-bit unsigned integer sequence.

Examples

type TagID = TagID UInt8

tagIDs :=
    Seq.uint8 TagID

uint16

uint16 : (UInt16 -> a) -> Description (Sequence a)

Declare a 16-bit unsigned integer sequence.

Examples

type ColorID = ColorID UInt16

colorIDs :=
    Seq.uint16 ColorID

uint32

uint32 : (UInt32 -> a) -> Description (Sequence a)

Declare a 32-bit unsigned integer sequence.

Examples

type PostID = PostID UInt32

postIDs :=
    Seq.uint32 PostID

uint64

uint64 : (UInt64 -> a) -> Description (Sequence a)

Declare a 64-bit unsigned integer sequence.

Examples

type TodoID = TodoID UInt64

todoIDs :=
    Seq.uint64 TodoID