Skip to content

upload

upload<T>(builder, metadata): T

Defined in: packages/forms/src/validate.ts:105

Mark a Drizzle text column as an upload key, capturing the storage filetype and per-field upload settings.

The metadata is stored on the same protected config object that v writes to, so the two helpers can be combined on a single column without conflict. introspectTable reads it back and promotes the column’s inputType to "upload".

T extends ColumnBuilderBase<ColumnBuilderBaseConfig<ColumnDataType, string>, object>

The Drizzle column builder type, preserved for chaining.

T

A Drizzle column builder (e.g., text("image_key")).

UploadFieldMetadata

The upload field configuration (filetype + options).

T

The same builder instance for inline chaining.

import { upload } from "@cfast/forms";
import { sqliteTable, text } from "drizzle-orm/sqlite-core";
export const products = sqliteTable("products", {
imageKey: upload(text("image_key"), {
filetype: "productImages",
accept: "image/*",
maxSize: 5 * 1024 * 1024,
}),
});