Skip to content

CreateTableBuilder

Josh Wright edited this page Jan 14, 2021 · 3 revisions

CreateTableBuilder

A builder with useful functions for creating a table.

public class CreateTableBuilder

Methods

addIndex(columns:isUnique:)

Add an index.

public func addIndex(columns: [String], isUnique: Bool)

It's name will be <tableName>_<columnName1>_<columnName2>... suffixed with key if it's unique or idx if not.

Parameters

  • columns: The names of the column(s) in this index.
  • isUnique: Whether this index will be unique.

increments(_:)

Adds an auto-incrementing Int column.

@discardableResult public func increments(_ column: String) -> CreateColumnBuilder<Int>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

int(_:)

Adds an Int column.

@discardableResult public func int(_ column: String) -> CreateColumnBuilder<Int>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

double(_:)

Adds a Double column.

@discardableResult public func double(_ column: String) -> CreateColumnBuilder<Double>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

string(_:length:)

Adds an String column.

@discardableResult public func string(_ column: String, length: StringLength = .limit(255)) -> CreateColumnBuilder<String>

Parameters

  • column: The name of the column to add.
  • length: The max length of this string. Defaults to .limit(255).

Returns

A builder for adding modifiers to the column.

uuid(_:)

Adds a UUID column.

@discardableResult public func uuid(_ column: String) -> CreateColumnBuilder<UUID>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

bool(_:)

Adds a Bool column.

@discardableResult public func bool(_ column: String) -> CreateColumnBuilder<Bool>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

date(_:)

Adds a Date column.

@discardableResult public func date(_ column: String) -> CreateColumnBuilder<Date>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

json(_:)

Adds a JSON column.

@discardableResult public func json(_ column: String) -> CreateColumnBuilder<SQLJSON>

Parameters

  • column: The name of the column to add.

Returns

A builder for adding modifiers to the column.

Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally