Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Type Reference

This section provides a reference for the types available in the Cloesce Schema Language.

All Types

Primitives

TypeDescription
stringBasic string data
realAny floating-point number
intAny signed integer
boolBoolean value (true or false)
dateDate value (ISO 8601)
blobBinary large object
jsonJSON data
streamUnbuffered binary stream of data
r2objectA Cloudflare R2 object, which includes metadata and an accessor for the object’s data stream.

Generics

TypeDescription
option<T>A nullable version of any type T
array<T>An array of any type T
partial<T>A version of a Model type T where all properties (recursive) are optional.
kvobject<T>A Cloudflare KV object, which includes metadata and a value of type T.

Objects

Any Model or Plain Old Object defined in your schema can be used as a type:

model User for Db {
    primary {
        id: int
    }

    column {
        name: string
    }
}

poo Profile {
    user: User // A reference to the User Model
    bio: string
}

SQLite Compatible Types

TypeSQLite Type
stringTEXT
realREAL
intINTEGER
boolINTEGER (0 or 1)
dateTEXT (ISO 8601)
blobBLOB
jsonTEXT (JSON)

Some areas of the schema will only accept types that are compatible with SQLite. By default, all of these types are NOT NULL in a SQLite database.

To allow NULL values, wrap the type in the option generic, e.g. option<string> (which is SQLite compatible).