Model
Date & Time
Signature
declare const Date: Date;Signature
interface Date extends transformOrFail<String, any> {}DateTimeFromDate
Signature
declare const DateTimeFromDate: DateTimeFromDate;DateTimeFromDate interface
Signature
interface DateTimeFromDate extends transform<any, any> {}DateTimeFromDateWithNow
Signature
declare const DateTimeFromDateWithNow: any;DateTimeFromNumberWithNow
Signature
declare const DateTimeFromNumberWithNow: any;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.
It is omitted from updates and is available for selection.
Signature
declare const DateTimeInsert: DateTimeInsert;DateTimeInsert interface
Signature
interface DateTimeInsert extends unknown<{
readonly insert: VariantSchema.Overrideable<DateTime.Utc, string>;
readonly json: typeof Schema.DateTimeUtc;
readonly select: typeof Schema.DateTimeUtc;
}> {}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.
It is omitted from updates and is available for selection.
Signature
declare const DateTimeInsertFromDate: DateTimeInsertFromDate;DateTimeInsertFromDate interface
Signature
interface DateTimeInsertFromDate extends unknown<{
readonly insert: VariantSchema.Overrideable<DateTime.Utc, globalThis.Date>;
readonly json: typeof Schema.DateTimeUtc;
readonly select: DateTimeFromDate;
}> {}DateTimeInsertFromNumber
A field that represents a date-time value that is inserted as the current DateTime.Utc. It is serialized as a number.
It is omitted from updates and is available for selection.
Signature
declare const DateTimeInsertFromNumber: DateTimeInsertFromNumber;DateTimeInsertFromNumber interface
Signature
interface DateTimeInsertFromNumber extends unknown<{
readonly insert: VariantSchema.Overrideable<DateTime.Utc, number>;
readonly json: typeof Schema.DateTimeUtcFromNumber;
readonly select: typeof Schema.DateTimeUtcFromNumber;
}> {}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.
It is set to the current DateTime.Utc on updates and inserts and is available for selection.
Signature
declare const DateTimeUpdate: DateTimeUpdate;DateTimeUpdate interface
Signature
interface DateTimeUpdate extends unknown<{
readonly insert: VariantSchema.Overrideable<DateTime.Utc, string>;
readonly json: typeof Schema.DateTimeUtc;
readonly select: typeof Schema.DateTimeUtc;
readonly update: VariantSchema.Overrideable<DateTime.Utc, string>;
}> {}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.
It is set to the current DateTime.Utc on updates and inserts and is available for selection.
Signature
declare const DateTimeUpdateFromDate: DateTimeUpdateFromDate;DateTimeUpdateFromDate interface
Signature
interface DateTimeUpdateFromDate extends unknown<{
readonly insert: VariantSchema.Overrideable<DateTime.Utc, globalThis.Date>;
readonly json: typeof Schema.DateTimeUtc;
readonly select: DateTimeFromDate;
readonly update: VariantSchema.Overrideable<DateTime.Utc, globalThis.Date>;
}> {}DateTimeUpdateFromNumber
A field that represents a date-time value that is updated as the current DateTime.Utc. It is serialized as a number.
It is set to the current DateTime.Utc on updates and inserts and is available for selection.
Signature
declare const DateTimeUpdateFromNumber: DateTimeUpdateFromNumber;DateTimeUpdateFromNumber interface
Signature
interface DateTimeUpdateFromNumber extends unknown<{
readonly insert: VariantSchema.Overrideable<DateTime.Utc, number>;
readonly json: typeof Schema.DateTimeUtcFromNumber;
readonly select: typeof Schema.DateTimeUtcFromNumber;
readonly update: VariantSchema.Overrideable<DateTime.Utc, number>;
}> {}DateTimeWithNow
Signature
declare const DateTimeWithNow: any;DateWithNow
Signature
declare const DateWithNow: any;Fields
Generated
A field that represents a column that is generated by the database.
It is available for selection and update, but not for insertion.
Signature
declare const Generated: <S extends any>(schema: S) => Generated<S>;Signature
interface Generated<S extends Schema.Schema.All | Schema.PropertySignature.All> extends unknown<{
readonly json: S;
readonly select: S;
readonly update: S;
}> {}GeneratedByApp
A field that represents a column that is generated by the application.
It is required by the database, but not by the JSON variants.
Signature
declare const GeneratedByApp: <S extends any>(schema: S) => GeneratedByApp<S>;GeneratedByApp interface
Signature
interface GeneratedByApp<
S extends Schema.Schema.All | Schema.PropertySignature.All,
> extends unknown<{
readonly insert: S;
readonly json: S;
readonly select: S;
readonly update: S;
}> {}Json
JsonFromString
A field that represents a JSON value stored as text in the database.
The "json" variants will use the object schema directly.
Signature
declare const JsonFromString: <S extends any>(schema: S) => JsonFromString<S>;JsonFromString interface
Signature
interface JsonFromString<
S extends Schema.Schema.All | Schema.PropertySignature.All,
> extends unknown<{
readonly insert: Schema.Schema<Schema.Schema.Type<S>, string, Schema.Schema.Context<S>>;
readonly json: S;
readonly jsonCreate: S;
readonly jsonUpdate: S;
readonly select: Schema.Schema<Schema.Schema.Type<S>, string, Schema.Schema.Context<S>>;
readonly update: Schema.Schema<Schema.Schema.Type<S>, string, Schema.Schema.Context<S>>;
}> {}Models
Signature
type Any = Schema.Schema.Any & {
readonly fields: Schema.Struct.Fields;
readonly insert: Schema.Schema.Any;
readonly json: Schema.Schema.Any;
readonly jsonCreate: Schema.Schema.Any;
readonly jsonUpdate: Schema.Schema.Any;
readonly update: Schema.Schema.Any;
};AnyNoContext type
Signature
type AnyNoContext = Schema.Schema.AnyNoContext & {
readonly fields: Schema.Struct.Fields;
readonly insert: Schema.Schema.AnyNoContext;
readonly json: Schema.Schema.AnyNoContext;
readonly jsonCreate: Schema.Schema.AnyNoContext;
readonly jsonUpdate: Schema.Schema.AnyNoContext;
readonly update: Schema.Schema.AnyNoContext;
};VariantsDatabase type
Signature
type VariantsDatabase = "select" | "insert" | "update";VariantsJson type
Signature
type VariantsJson = "json" | "jsonCreate" | "jsonUpdate";Optional
FieldOption
Convert a field to one that is optional for all variants.
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 any>(
self: Field,
) => Field extends Any
? FieldOption<Field>
: Field extends Field<S>
? Field<{
[K in string | number | symbol]: S[K] extends Any
? K extends VariantsDatabase
? OptionFromNullOr<S[K]>
: optionalWith<
S[K],
{
as: "Option";
nullable: true;
}
>
: never;
}>
: never;FieldOption interface
Convert a field to one that is optional for all variants.
For the database variants, it will accept nullable values. For the JSON variants, it will also accept missing keys.
Signature
interface FieldOption<S extends Schema.Schema.Any> extends unknown<{
readonly insert: Schema.OptionFromNullOr<S>;
readonly json: Schema.optionalWith<
S,
{
as: "Option";
}
>;
readonly jsonCreate: Schema.optionalWith<
S,
{
as: "Option";
nullable: true;
}
>;
readonly jsonUpdate: Schema.optionalWith<
S,
{
as: "Option";
nullable: true;
}
>;
readonly select: Schema.OptionFromNullOr<S>;
readonly update: Schema.OptionFromNullOr<S>;
}> {}Other
Signature
declare const Class: any;Signature
declare const extract: any;Signature
declare const Field: any;Signature
declare const fieldEvolve: any;Signature
declare const FieldExcept: any;Signature
declare const fieldFromKey: any;Signature
declare const FieldOnly: any;Signature
declare const Struct: any;Signature
declare const Union: any;Overrideable
Repository
makeDataLoaders
Create some simple data loaders from a model.
Signature
declare function makeDataLoaders<S extends any, Id extends string | number | symbol>(
Model: S,
options: {
readonly idColumn: Id;
readonly maxBatchSize?: number;
readonly spanPrefix: string;
readonly tableName: string;
readonly window: DurationInput;
},
): Effect<
{
readonly delete: (id: Type<S["fields"][Id]>) => Effect<void>;
readonly findById: (id: Type<S["fields"][Id]>) => Effect<Option<S["Type"]>>;
readonly insert: (insert: S["insert"]["Type"]) => Effect<S["Type"]>;
readonly insertVoid: (insert: S["insert"]["Type"]) => Effect<void>;
},
never,
SqlClient | Scope
>;makeRepository
Create a simple CRUD repository from a model.
Signature
declare function makeRepository<S extends any, Id extends string | number | symbol>(
Model: S,
options: {
readonly idColumn: Id;
readonly spanPrefix: string;
readonly tableName: string;
},
): Effect<
{
readonly delete: (id: Type<S["fields"][Id]>) => Effect<void, never, Context<S["fields"][Id]>>;
readonly findById: (id: Type<S["fields"][Id]>) => Effect<Option<S["Type"]>, never, any>;
readonly insert: (
insert: S["insert"]["Type"],
) => Effect<S["Type"], never, S["Context"] | S["insert"]["Context"]>;
readonly insertVoid: (
insert: S["insert"]["Type"],
) => Effect<void, never, S["Context"] | S["insert"]["Context"]>;
readonly update: (
update: S["update"]["Type"],
) => Effect<S["Type"], never, S["Context"] | S["update"]["Context"]>;
readonly updateVoid: (
update: S["update"]["Type"],
) => Effect<void, never, S["Context"] | S["update"]["Context"]>;
},
never,
SqlClient
>;Sensitive
A field that represents a sensitive value that should not be exposed in the JSON variants.
Signature
declare const Sensitive: <S extends any>(schema: S) => Sensitive<S>;Signature
interface Sensitive<S extends Schema.Schema.All | Schema.PropertySignature.All> extends unknown<{
readonly insert: S;
readonly select: S;
readonly update: S;
}> {}Uuid
BooleanFromNumber
A boolean parsed from 0 or 1
Signature
declare class BooleanFromNumber extends any {
constructor();
}UuidV4Insert
A field that represents a binary UUID v4 that is generated on inserts.
Signature
declare const UuidV4Insert: <B extends string | symbol>(schema: brand<any, B>) => UuidV4Insert<B>;UuidV4Insert interface
Signature
interface UuidV4Insert<B extends string | symbol> extends unknown<{
readonly insert: VariantSchema.Overrideable<Uint8Array & Brand<B>, Uint8Array>;
readonly json: Schema.brand<typeof Schema.Uint8ArrayFromSelf, B>;
readonly select: Schema.brand<typeof Schema.Uint8ArrayFromSelf, B>;
readonly update: Schema.brand<typeof Schema.Uint8ArrayFromSelf, B>;
}> {}UuidV4WithGenerate
Signature
declare function UuidV4WithGenerate<B extends string | symbol>(
schema: brand<any, B>,
): Overrideable<Uint8Array<ArrayBufferLike> & Brand<B>, Uint8Array<ArrayBufferLike>>;
A schema for a
DateTime.Utcthat is serialized as a date string in the formatYYYY-MM-DD.