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. These types can be used to define your application’s data Models, APIs, Data Sources, and more.

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.
paginated<T>A paginated list of items of type T, which includes the items and pagination metadata. Useful for wrapping KV and R2 prefix lists.

Objects

Any Model or Plain Old Object defined in your schema can be referenced as a type. For example, to have a Plain Old Object that references a Model:

model User {
    primary {
        id: int
    }
    column {
        name: string
    }
}

poo Profile {
    user: User
    bio: string
}

SQLite Compatible Types

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

By default, all of these types are NOT NULL in the database. To allow NULL values, wrap the type in the option generic.