Skip to content

ExtendedTable

ExtendedTable(
name: String,
primaryKey: String = "id",
defaultOrderBy: String = "created_at DESC",
columns: [ColumnBuilder]
)
.text("field_name")
.text("email").email()
.text("website").url()
.text("user_id").uuid()
.integer("age")
.real("price")
.encrypted() // Encrypt field
.nullable() // Optional field
.notNull() // Required field
.default(value) // Default value
.default(.now) // Timestamp default
.references(table) // Foreign key
.enum(enumType) // Enum type

See Validation Guide for complete validation API.

Convert to PowerSync table for schema definition.

Generate field configuration for CRUD operations.

Get all enum types used by this table.

Get all tables referenced by foreign keys in this table.

getForeignKeys() -> [(column: String, foreignKey: ForeignKey)]

Section titled “getForeignKeys() -> [(column: String, foreignKey: ForeignKey)]”

Get all foreign key relationships.

Generate Swift model struct code (struct definition only).

Generate complete Swift file with imports.

generateDrizzleSchema(includeImports: Bool = false) -> String

Section titled “generateDrizzleSchema(includeImports: Bool = false) -> String”

Generate Drizzle ORM schema code (TypeScript). Use includeImports: true to include import statements.

Generate complete TypeScript file with imports.

Generate SQL CREATE TABLE statement with defaults, foreign keys, and triggers.

generateForeignKeyConstraints() -> [String]

Section titled “generateForeignKeyConstraints() -> [String]”

Generate SQL foreign key constraint statements.