Skip to main content
Module

x/cotton/mod.ts>ColumnBuilder

SQL Database Toolkit for Deno
Latest
class ColumnBuilder
import { ColumnBuilder } from "https://deno.land/x/cotton@v0.7.5/mod.ts";

Represents a table column for Schema

Constructors

new
ColumnBuilder(
name: string,
type: keyof COLUMN_TYPES,
length?: number,
)

Properties

private
defaultValue: any
private
isDefaultValueAnExpression: boolean
private
isNotNull: boolean
private
isPrimaryKey: boolean
private
isUnique: boolean
private
isUnsigned: boolean

Methods

private
getDefaultValueSQL(dialect: DatabaseDialect): string | null

Get the default value text of the column

default(value: any, isExpression?: boolean)

Set the default value of this column

Add the NOT NULL constraint

Set this column to be the PRIMARY KEY

toSQL(dialect: DatabaseDialect): string

Generate the SQL column definition

Add the UNIQUE constraint

Make this integer column unsigned