Model.ts
Model.ts overview
Section titled “Model.ts overview”Defines schema-backed domain models with separate database and JSON shapes.
A model keeps one field declaration as the source of truth and derives variants for selecting, inserting, updating, and JSON encoding. This is useful when the database shape is not exactly the same as the public API shape, such as generated ids, audit timestamps, nullable columns, private fields, or values that need different encodings at different boundaries. Each generated variant is its own schema, so callers can validate or encode the shape that matches the operation they are performing.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”- DateTime
- Date
- Date (interface)
- DateTimeFromDateWithNow
- DateTimeFromNumberWithNow
- DateTimeInsert
- DateTimeInsert (interface)
- DateTimeInsertFromDate
- DateTimeInsertFromDate (interface)
- DateTimeInsertFromNumber
- DateTimeInsertFromNumber (interface)
- DateTimeUpdate
- DateTimeUpdate (interface)
- DateTimeUpdateFromDate
- DateTimeUpdateFromDate (interface)
- DateTimeUpdateFromNumber
- DateTimeUpdateFromNumber (interface)
- DateTimeWithNow
- DateWithNow
- Uint8Array
- booleans
- constructors
- extraction
- fields
- generated
- models
- optional
- overrideable
- sensitive
- uuid
DateTime
Section titled “DateTime”Schema for a DateTime.Utc that is serialized as a date string in the
format YYYY-MM-DD.
Signature
declare const Date: DateSince v4.0.0
Date (interface)
Section titled “Date (interface)”Schema type for a DateTime.Utc date-only value encoded as a YYYY-MM-DD
string.
Signature
export interface Date extends Schema.decodeTo<Schema.instanceOf<DateTime.Utc>, Schema.String> {}Since v4.0.0
DateTimeFromDateWithNow
Section titled “DateTimeFromDateWithNow”Schema for an overrideable UTC date-time field encoded as a JavaScript Date
and defaulted to the current DateTime.Utc.
Signature
declare const DateTimeFromDateWithNow: VariantSchema.Overrideable<Schema.DateTimeUtcFromDate>Since v4.0.0
DateTimeFromNumberWithNow
Section titled “DateTimeFromNumberWithNow”Schema for an overrideable UTC date-time field encoded as milliseconds and
defaulted to the current DateTime.Utc.
Signature
declare const DateTimeFromNumberWithNow: VariantSchema.Overrideable<Schema.DateTimeUtcFromMillis>Since v4.0.0
DateTimeInsert
Section titled “DateTimeInsert”A field that represents a date-time value that is inserted as the current
DateTime.Utc. It is serialized as a string for the database.
Details
It is omitted from updates and is available for selection.
Signature
declare const DateTimeInsert: DateTimeInsertSince v4.0.0
DateTimeInsert (interface)
Section titled “DateTimeInsert (interface)”Variant field type for a UTC date-time stored as a string, defaulted to the current time on insert, available for selection, and omitted from updates.
Signature
export interface DateTimeInsert extends VariantSchema.Field<{ readonly select: Schema.DateTimeUtcFromString readonly insert: VariantSchema.Overrideable<Schema.DateTimeUtcFromString> readonly json: Schema.DateTimeUtcFromString}> {}Since v4.0.0
DateTimeInsertFromDate
Section titled “DateTimeInsertFromDate”A field that represents a date-time value that is inserted as the current
DateTime.Utc. It is serialized as a Date for the database.
Details
It is omitted from updates and is available for selection.
Signature
declare const DateTimeInsertFromDate: DateTimeInsertFromDateSince v4.0.0
DateTimeInsertFromDate (interface)
Section titled “DateTimeInsertFromDate (interface)”Variant field type for a UTC date-time stored as a JavaScript Date in
database variants, encoded as a string for JSON, and defaulted on insert.
Signature
export interface DateTimeInsertFromDate extends VariantSchema.Field<{ readonly select: Schema.DateTimeUtcFromDate readonly insert: VariantSchema.Overrideable<Schema.DateTimeUtcFromDate> readonly json: Schema.DateTimeUtcFromString}> {}Since v4.0.0
DateTimeInsertFromNumber
Section titled “DateTimeInsertFromNumber”A field that represents a date-time value that is inserted as the current
DateTime.Utc. It is serialized as a number.
Details
It is omitted from updates and is available for selection.
Signature
declare const DateTimeInsertFromNumber: DateTimeInsertFromNumberSince v4.0.0
DateTimeInsertFromNumber (interface)
Section titled “DateTimeInsertFromNumber (interface)”Variant field type for a UTC date-time encoded as milliseconds and defaulted to the current time on insert.
Signature
export interface DateTimeInsertFromNumber extends VariantSchema.Field<{ readonly select: Schema.DateTimeUtcFromMillis readonly insert: VariantSchema.Overrideable<Schema.DateTimeUtcFromMillis> readonly json: Schema.DateTimeUtcFromMillis}> {}Since v4.0.0
DateTimeUpdate
Section titled “DateTimeUpdate”A field that represents a date-time value that is updated as the current
DateTime.Utc. It is serialized as a string for the database.
Details
It is set to the current DateTime.Utc on updates and inserts and is
available for selection.
Signature
declare const DateTimeUpdate: DateTimeUpdateSince v4.0.0
DateTimeUpdate (interface)
Section titled “DateTimeUpdate (interface)”Variant field type for a UTC date-time stored as a string and defaulted to the current time on both inserts and updates.
Signature
export interface DateTimeUpdate extends VariantSchema.Field<{ readonly select: Schema.DateTimeUtcFromString readonly insert: VariantSchema.Overrideable<Schema.DateTimeUtcFromString> readonly update: VariantSchema.Overrideable<Schema.DateTimeUtcFromString> readonly json: Schema.DateTimeUtcFromString}> {}Since v4.0.0
DateTimeUpdateFromDate
Section titled “DateTimeUpdateFromDate”A field that represents a date-time value that is updated as the current
DateTime.Utc. It is serialized as a Date for the database.
Details
It is set to the current DateTime.Utc on updates and inserts and is
available for selection.
Signature
declare const DateTimeUpdateFromDate: DateTimeUpdateFromDateSince v4.0.0
DateTimeUpdateFromDate (interface)
Section titled “DateTimeUpdateFromDate (interface)”Variant field type for a UTC date-time stored as a JavaScript Date in
database variants, encoded as a string for JSON, and defaulted on inserts and
updates.
Signature
export interface DateTimeUpdateFromDate extends VariantSchema.Field<{ readonly select: Schema.DateTimeUtcFromDate readonly insert: VariantSchema.Overrideable<Schema.DateTimeUtcFromDate> readonly update: VariantSchema.Overrideable<Schema.DateTimeUtcFromDate> readonly json: Schema.DateTimeUtcFromString}> {}Since v4.0.0
DateTimeUpdateFromNumber
Section titled “DateTimeUpdateFromNumber”A field that represents a date-time value that is updated as the current
DateTime.Utc. It is serialized as a number.
Details
It is set to the current DateTime.Utc on updates and inserts and is
available for selection.
Signature
declare const DateTimeUpdateFromNumber: DateTimeUpdateFromNumberSince v4.0.0
DateTimeUpdateFromNumber (interface)
Section titled “DateTimeUpdateFromNumber (interface)”Variant field type for a UTC date-time encoded as milliseconds and defaulted to the current time on both inserts and updates.
Signature
export interface DateTimeUpdateFromNumber extends VariantSchema.Field<{ readonly select: Schema.DateTimeUtcFromMillis readonly insert: VariantSchema.Overrideable<Schema.DateTimeUtcFromMillis> readonly update: VariantSchema.Overrideable<Schema.DateTimeUtcFromMillis> readonly json: Schema.DateTimeUtcFromMillis}> {}Since v4.0.0
DateTimeWithNow
Section titled “DateTimeWithNow”Schema for an overrideable UTC date-time field encoded as a string and
defaulted to the current DateTime.Utc.
Signature
declare const DateTimeWithNow: VariantSchema.Overrideable<Schema.DateTimeUtcFromString>Since v4.0.0
DateWithNow
Section titled “DateWithNow”Schema for an overrideable UTC date-only field whose constructor default is the current date with the time component removed.
Signature
declare const DateWithNow: VariantSchema.Overrideable<Date>Since v4.0.0
Uint8Array
Section titled “Uint8Array”Uint8Array
Section titled “Uint8Array”Schema for binary Uint8Array values backed by an ArrayBuffer.
Signature
declare const Uint8Array: Schema.instanceOf<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>Since v4.0.0
booleans
Section titled “booleans”BooleanSqlite
Section titled “BooleanSqlite”Schema for sqlite booleans that are represented as 0 | 1 in database
variants and boolean in JSON variants.
Signature
declare const BooleanSqlite: BooleanSqliteSince v4.0.0
BooleanSqlite (interface)
Section titled “BooleanSqlite (interface)”Variant field type for SQLite booleans stored as 0 | 1 in database variants
and exposed as boolean in JSON variants.
Signature
export interface BooleanSqlite extends VariantSchema.Field<{ readonly select: Schema.BooleanFromBit readonly insert: Schema.BooleanFromBit readonly update: Schema.BooleanFromBit readonly json: Schema.Boolean readonly jsonCreate: Schema.Boolean readonly jsonUpdate: Schema.Boolean}> {}Since v4.0.0
constructors
Section titled “constructors”Creates domain model schemas with common database and JSON API variants.
Example (Defining a variant model class)
import { Schema } from "effect"import { Model } from "effect/unstable/schema"
export const GroupId = Schema.Number.pipe(Schema.brand("GroupId"))
export class Group extends Model.Class<Group>("Group")({ id: Model.GeneratedByDb(GroupId), name: Schema.String, createdAt: Model.DateTimeInsertFromDate, updatedAt: Model.DateTimeUpdateFromDate}) {}
// schema used for selectsGroup
// schema used for insertsGroup.insert
// schema used for updatesGroup.update
// schema used for json apiGroup.jsonGroup.jsonCreateGroup.jsonUpdate
// you can also turn them into classesclass GroupJson extends Schema.Class<GroupJson>("GroupJson")(Group.json) { get upperName() { return this.name.toUpperCase() }}Signature
declare const Class: <Self = never>( identifier: string) => <const Fields extends VariantSchema.Struct.Fields>( fields: Fields & VariantSchema.Struct.Validate<Fields, "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">, annotations?: | Schema.Annotations.Declaration< Self, readonly [Schema.Struct<VariantSchema.ExtractFields<"select", Fields, true>>] > | undefined) => [Self] extends [never] ? "Missing `Self` generic - use `class Self extends Class<Self>()({ ... })`" : VariantSchema.Class<Self, Fields, Schema.Struct<VariantSchema.ExtractFields<"select", Fields, true>>> & { readonly insert: Schema.Struct<{ [K in keyof VariantSchema.ExtractFields<"insert", Fields, false>]: VariantSchema.ExtractFields< "insert", Fields, false >[K] }> readonly update: Schema.Struct<{ [K in keyof VariantSchema.ExtractFields<"update", Fields, false>]: VariantSchema.ExtractFields< "update", Fields, false >[K] }> readonly json: Schema.Struct<{ [K in keyof VariantSchema.ExtractFields<"json", Fields, false>]: VariantSchema.ExtractFields< "json", Fields, false >[K] }> readonly jsonCreate: Schema.Struct<{ [K in keyof VariantSchema.ExtractFields<"jsonCreate", Fields, false>]: VariantSchema.ExtractFields< "jsonCreate", Fields, false >[K] }> readonly jsonUpdate: Schema.Struct<{ [K in keyof VariantSchema.ExtractFields<"jsonUpdate", Fields, false>]: VariantSchema.ExtractFields< "jsonUpdate", Fields, false >[K] }> readonly select: Schema.Struct<{ [K in keyof VariantSchema.ExtractFields<"select", Fields, false>]: VariantSchema.ExtractFields< "select", Fields, false >[K] }> }Since v4.0.0
JsonFromString
Section titled “JsonFromString”A field that represents a JSON value stored as text in the database.
Details
The “json” variants will use the object schema directly.
Signature
declare const JsonFromString: <S extends Schema.Top>(schema: S) => JsonFromString<S>Since v4.0.0
Struct
Section titled “Struct”Creates a variant struct from model field definitions.
Signature
declare const Struct: <const A extends VariantSchema.Struct.Fields>( fields: A & VariantSchema.Struct.Validate<A, "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">) => VariantSchema.Struct<A>Since v4.0.0
Creates a union over the default and generated variant schemas of multiple variant structs.
Signature
declare const Union: <const Members extends ReadonlyArray<VariantSchema.Struct<any>>>( members: Members) => VariantSchema.Union<Members> & VariantSchema.Union.Variants<Members, "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">Since v4.0.0
extraction
Section titled “extraction”extract
Section titled “extract”Extracts a generated variant schema from a model or variant struct.
Signature
declare const extract: { <V extends "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">( variant: V ): <A extends VariantSchema.Struct<any>>(self: A) => VariantSchema.Extract<V, A, V extends "select" ? true : false> < V extends "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select", A extends VariantSchema.Struct<any> >( self: A, variant: V ): VariantSchema.Extract<V, A, V extends "select" ? true : false>}Since v4.0.0
fields
Section titled “fields”Creates a variant field from schemas keyed by variant name.
Signature
declare const Field: < const A extends VariantSchema.Field.ConfigWithKeys< "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select" >>( config: A & { readonly [K in Exclude<keyof A, "insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">]: never }) => VariantSchema.Field<A>Since v4.0.0
FieldExcept
Section titled “FieldExcept”Creates a variant field that applies a schema to every variant except the supplied keys.
Signature
declare const FieldExcept: < const Keys extends ReadonlyArray<"insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">>( keys: Keys) => <S extends Schema.Top>( schema: S) => VariantSchema.Field<{ readonly [K in | Exclude<"insert", Keys[number]> | Exclude<"update", Keys[number]> | Exclude<"json", Keys[number]> | Exclude<"jsonCreate", Keys[number]> | Exclude<"jsonUpdate", Keys[number]> | Exclude<"select", Keys[number]>]: S}>Since v4.0.0
FieldOnly
Section titled “FieldOnly”Creates a variant field that applies a schema only to the supplied variants.
Signature
declare const FieldOnly: < const Keys extends ReadonlyArray<"insert" | "update" | "json" | "jsonCreate" | "jsonUpdate" | "select">>( keys: Keys) => <S extends Schema.Top>(schema: S) => VariantSchema.Field<{ readonly [K in Keys[number]]: S }>Since v4.0.0
fieldEvolve
Section titled “fieldEvolve”Transforms schemas inside a variant field or plain schema by variant name.
Signature
declare const fieldEvolve: { < Self extends VariantSchema.Field<any> | Schema.Top, const Mapping extends Self extends VariantSchema.Field<infer S extends VariantSchema.Field.Config> ? { readonly [K in keyof S]?: ((variant: S[K]) => Schema.Top) | undefined } : { readonly insert?: ((variant: Self) => Schema.Top) | undefined readonly update?: ((variant: Self) => Schema.Top) | undefined readonly json?: ((variant: Self) => Schema.Top) | undefined readonly jsonCreate?: ((variant: Self) => Schema.Top) | undefined readonly jsonUpdate?: ((variant: Self) => Schema.Top) | undefined readonly select?: ((variant: Self) => Schema.Top) | undefined } >( f: Mapping ): ( self: Self ) => VariantSchema.Field< Self extends VariantSchema.Field<infer S extends VariantSchema.Field.Config> ? { readonly [K in keyof S]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType<Mapping[K]> : S[K] : S[K] } : { readonly insert: "insert" extends keyof Mapping ? Mapping[keyof Mapping & "insert"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "insert"]> : Self : Self readonly update: "update" extends keyof Mapping ? Mapping[keyof Mapping & "update"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "update"]> : Self : Self readonly json: "json" extends keyof Mapping ? Mapping[keyof Mapping & "json"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "json"]> : Self : Self readonly jsonCreate: "jsonCreate" extends keyof Mapping ? Mapping[keyof Mapping & "jsonCreate"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "jsonCreate"]> : Self : Self readonly jsonUpdate: "jsonUpdate" extends keyof Mapping ? Mapping[keyof Mapping & "jsonUpdate"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "jsonUpdate"]> : Self : Self readonly select: "select" extends keyof Mapping ? Mapping[keyof Mapping & "select"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "select"]> : Self : Self } > < Self extends VariantSchema.Field<any> | Schema.Top, const Mapping extends Self extends VariantSchema.Field<infer S extends VariantSchema.Field.Config> ? { readonly [K in keyof S]?: ((variant: S[K]) => Schema.Top) | undefined } : { readonly insert?: ((variant: Self) => Schema.Top) | undefined readonly update?: ((variant: Self) => Schema.Top) | undefined readonly json?: ((variant: Self) => Schema.Top) | undefined readonly jsonCreate?: ((variant: Self) => Schema.Top) | undefined readonly jsonUpdate?: ((variant: Self) => Schema.Top) | undefined readonly select?: ((variant: Self) => Schema.Top) | undefined } >( self: Self, f: Mapping ): VariantSchema.Field< Self extends VariantSchema.Field<infer S extends VariantSchema.Field.Config> ? { readonly [K in keyof S]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType<Mapping[K]> : S[K] : S[K] } : { readonly insert: "insert" extends keyof Mapping ? Mapping[keyof Mapping & "insert"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "insert"]> : Self : Self readonly update: "update" extends keyof Mapping ? Mapping[keyof Mapping & "update"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "update"]> : Self : Self readonly json: "json" extends keyof Mapping ? Mapping[keyof Mapping & "json"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "json"]> : Self : Self readonly jsonCreate: "jsonCreate" extends keyof Mapping ? Mapping[keyof Mapping & "jsonCreate"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "jsonCreate"]> : Self : Self readonly jsonUpdate: "jsonUpdate" extends keyof Mapping ? Mapping[keyof Mapping & "jsonUpdate"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "jsonUpdate"]> : Self : Self readonly select: "select" extends keyof Mapping ? Mapping[keyof Mapping & "select"] extends (arg: any) => any ? ReturnType<Mapping[keyof Mapping & "select"]> : Self : Self } >}Since v4.0.0
fields
Section titled “fields”Returns the variant field definitions stored on a model or variant struct.
Signature
declare const fields: <A extends VariantSchema.Struct<any>>(self: A) => A[typeof VariantSchema.TypeId]Since v4.0.0
generated
Section titled “generated”GeneratedByApp
Section titled “GeneratedByApp”A field that represents a value generated by the application and present in database variants and the read JSON variant, but omitted from JSON create and update variants.
Signature
declare const GeneratedByApp: <S extends Schema.Top>(schema: S) => GeneratedByApp<S>Since v4.0.0
GeneratedByApp (interface)
Section titled “GeneratedByApp (interface)”Variant field type for an application-generated value that is present in database variants and read JSON, but omitted from JSON create and update variants.
Signature
export interface GeneratedByApp<S extends Schema.Top> extends VariantSchema.Field<{ readonly select: S readonly insert: S readonly update: S readonly json: S}> {}Since v4.0.0
GeneratedByDb
Section titled “GeneratedByDb”Creates a variant field for a database-generated column available in read variants only.
Details
The field is included in select and json, and omitted from insert,
update, jsonCreate, and jsonUpdate.
See
Fieldfor generated columns that need a custom variant set, such as primary keys used in update payloads.
Signature
declare const GeneratedByDb: <S extends Schema.Top>(schema: S) => GeneratedByDb<S>Since v4.0.0
GeneratedByDb (interface)
Section titled “GeneratedByDb (interface)”Variant field type for a database-generated column that is present in read variants only.
Details
The field is included in select and json, and omitted from insert,
update, jsonCreate, and jsonUpdate.
See
Fieldfor generated columns that need a custom variant set, such as primary keys used in update payloads.
Signature
export interface GeneratedByDb<S extends Schema.Top> extends VariantSchema.Field<{ readonly select: S readonly json: S}> {}Since v4.0.0
models
Section titled “models”Any (type alias)
Section titled “Any (type alias)”Base shape of a variant model schema, including its fields and the generated database and JSON variant schemas.
Signature
type Any = Schema.Top & { readonly fields: Schema.Struct.Fields readonly insert: Schema.Top readonly update: Schema.Top readonly json: Schema.Top readonly jsonCreate: Schema.Top readonly jsonUpdate: Schema.Top}Since v4.0.0
JsonFromString (interface)
Section titled “JsonFromString (interface)”Variant field type for a JSON value stored as text in database variants and exposed through the supplied schema in JSON variants.
Signature
export interface JsonFromString<S extends Schema.Top> extends VariantSchema.Field<{ readonly select: Schema.fromJsonString<S> readonly insert: Schema.fromJsonString<S> readonly update: Schema.fromJsonString<S> readonly json: S readonly jsonCreate: S readonly jsonUpdate: S}> {}Since v4.0.0
VariantsDatabase (type alias)
Section titled “VariantsDatabase (type alias)”Database-facing variant names generated for model schemas.
Signature
type VariantsDatabase = "select" | "insert" | "update"Since v4.0.0
VariantsJson (type alias)
Section titled “VariantsJson (type alias)”JSON API-facing variant names generated for model schemas.
Signature
type VariantsJson = "json" | "jsonCreate" | "jsonUpdate"Since v4.0.0
optional
Section titled “optional”FieldOption
Section titled “FieldOption”Converts a field to one that is optional for all variants.
Details
For the database variants, it will accept nullable values.
For the JSON variants, it will also accept missing keys.
Signature
declare const FieldOption: <Field extends VariantSchema.Field<any> | Schema.Top>( self: Field) => Field extends Schema.Top ? FieldOption<Field> : Field extends VariantSchema.Field<infer S> ? VariantSchema.Field<{ readonly [K in keyof S]: S[K] extends Schema.Top ? K extends VariantsDatabase ? Schema.OptionFromNullOr<S[K]> : optionalOption<S[K]> : never }> : neverSince v4.0.0
FieldOption (interface)
Section titled “FieldOption (interface)”Convert a field to one that is optional for all variants.
Details
For the database variants, it will accept nullable values.
For the JSON variants, it will also accept missing keys.
Signature
export interface FieldOption<S extends Schema.Top> extends VariantSchema.Field<{ readonly select: Schema.OptionFromNullOr<S> readonly insert: Schema.OptionFromNullOr<S> readonly update: Schema.OptionFromNullOr<S> readonly json: optionalOption<S> readonly jsonCreate: optionalOption<S> readonly jsonUpdate: optionalOption<S>}> {}Since v4.0.0
optionalOption
Section titled “optionalOption”Creates a schema for optional keys that decodes missing or null encoded values
through Option and encodes Option values back to optional nullable keys.
Signature
declare const optionalOption: <S extends Schema.Constraint>(schema: S) => optionalOption<S>Since v4.0.0
optionalOption (interface)
Section titled “optionalOption (interface)”Schema type for an optional object key whose encoded value may be missing or
null and whose decoded value is an Option.
Signature
export interface optionalOption<S extends Schema.Constraint> extends Schema.decodeTo< Schema.Option<Schema.toType<S>>, Schema.optionalKey<Schema.NullOr<S>>> {}Since v4.0.0
overrideable
Section titled “overrideable”Override
Section titled “Override”Marks a value as an explicit override for fields that otherwise use an overrideable default.
Signature
declare const Override: <A>(value: A) => A & Brand<"Override">Since v4.0.0
sensitive
Section titled “sensitive”Sensitive
Section titled “Sensitive”A field that represents a sensitive value that should not be exposed in the JSON variants.
Signature
declare const Sensitive: <S extends Schema.Top>(schema: S) => Sensitive<S>Since v4.0.0
Sensitive (interface)
Section titled “Sensitive (interface)”Variant field type for a sensitive value that is available to database variants and omitted from all JSON variants.
Signature
export interface Sensitive<S extends Schema.Top> extends VariantSchema.Field<{ readonly select: S readonly insert: S readonly update: S}> {}Since v4.0.0
UuidV4BytesInsert
Section titled “UuidV4BytesInsert”A field that represents a binary UUID v4 that is generated on inserts.
Signature
declare const UuidV4BytesInsert: <const B extends string>( schema: Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B>) => UuidV4BytesInsert<B>Since v4.0.0
UuidV4BytesInsert (interface)
Section titled “UuidV4BytesInsert (interface)”Variant field type for a branded binary UUID v4 value whose insert variant generates a UUID by default.
Signature
export interface UuidV4BytesInsert<B extends string> extends VariantSchema.Field<{ readonly select: Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B> readonly insert: Schema.withConstructorDefault<Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B>> readonly update: Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B> readonly json: Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B>}> {}Since v4.0.0
UuidV4BytesWithGenerate
Section titled “UuidV4BytesWithGenerate”Adds a constructor default that generates a binary UUID v4 for a branded
Uint8Array schema.
Signature
declare const UuidV4BytesWithGenerate: <B extends string>( schema: Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B>) => Schema.withConstructorDefault<Schema.brand<Schema.instanceOf<Uint8Array<ArrayBuffer>>, B>>Since v4.0.0
UuidV4Insert
Section titled “UuidV4Insert”A field that represents a string UUID v4 that is generated on inserts.
Signature
declare const UuidV4Insert: <const B extends string>(schema: Schema.brand<Schema.String, B>) => UuidV4Insert<B>Since v4.0.0
UuidV4Insert (interface)
Section titled “UuidV4Insert (interface)”Variant field type for a branded string UUID v4 value whose insert variant generates a UUID by default.
Signature
export interface UuidV4Insert<B extends string> extends VariantSchema.Field<{ readonly select: Schema.brand<Schema.String, B> readonly insert: Schema.withConstructorDefault<Schema.brand<Schema.String, B>> readonly update: Schema.brand<Schema.String, B> readonly json: Schema.brand<Schema.String, B>}> {}Since v4.0.0
UuidV4WithGenerate
Section titled “UuidV4WithGenerate”Adds a constructor default that generates a string UUID v4.
Signature
declare const UuidV4WithGenerate: <B extends string>( schema: Schema.brand<Schema.String, B>) => Schema.withConstructorDefault<Schema.brand<Schema.String, B>>Since v4.0.0
UuidV7Insert
Section titled “UuidV7Insert”A field that represents a string UUID v7 that is generated on inserts.
Signature
declare const UuidV7Insert: <const B extends string>(schema: Schema.brand<Schema.String, B>) => UuidV7Insert<B>Since v4.0.0
UuidV7Insert (interface)
Section titled “UuidV7Insert (interface)”Variant field type for a branded string UUID v7 value whose insert variant generates a UUID by default.
Signature
export interface UuidV7Insert<B extends string> extends VariantSchema.Field<{ readonly select: Schema.brand<Schema.String, B> readonly insert: Schema.withConstructorDefault<Schema.brand<Schema.String, B>> readonly update: Schema.brand<Schema.String, B> readonly json: Schema.brand<Schema.String, B>}> {}Since v4.0.0
UuidV7WithGenerate
Section titled “UuidV7WithGenerate”Adds a constructor default that generates a string UUID v7.
Signature
declare const UuidV7WithGenerate: <B extends string>( schema: Schema.brand<Schema.String, B>) => Schema.withConstructorDefault<Schema.brand<Schema.String, B>>Since v4.0.0