From 4940a22a5aceb4fbf4141eb1ac5583fc5f1ae361 Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Wed, 21 Jul 2021 17:24:05 +0700 Subject: [PATCH] docs: column types --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4554cf6..d07a757 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ func main() { StringColumn("email", "NOT NULL", "UNIQUE"). // See the list of available column definition type through pkg.go.dev or scroll down below. TextColumn("password"). + // Or add your custom types + AddColumn(bob.ColumnDef{Name: "tableName", Type: "customType", Extras: []string{"NOT NULL"}}). ToSql() if err != nil { // handle your error @@ -36,6 +38,25 @@ func main() { } ``` +Available column definition types: +* `StringColumn()` - Default to `VARCHAR(255)` +* `TextColumn()` - Default to `TEXT` +* `UUIDColumn()` - Defaults to `UUID` +* `BooleanColumn()` - Defaults to `BOOLEAN` +* `IntegerColumn()` - Defaults to `INTEGER`. Postgres and SQLite only. +* `IntColumn()` - Defaults to `INT`. MySQL and MSSQL only. +* `RealColumn()` - Defaults to `REAL`. Postgres, MSSQL, and SQLite only. +* `FloatColumn()` - Defaults to `FLOAT`. Postgres and SQLite only. +* `DateTimeColumn()` - Defaults to `DATETIME`. +* `TimeStampColumn()` - Defaults to `TIMESTAMP`. +* `TimeColumn()` - Defaults to `TIME`. +* `DateColumn()` - Defaults to `DATE`. +* `JSONColumn()` - Dafults to `JSON`. MySQL and Postgres only. +* `JSONBColumn()` - Defaults to `JSONB`. Postgres only. +* `BlobColumn()` - Defaults to `BLOB`. MySQL and SQLite only. + +For any other types, please use `AddColumn()`. + Another builder of `bob.CreateTableIfNotExists()` is also available. ### Check if a table exists @@ -87,7 +108,6 @@ Available placeholder formats: * `bob.Colon` - `INSERT INTO "users" (name) VALUES (:1)` * `bob.AtP` - `INSERT INTO "users" (name) VALUES (@p1)` - ### With pgx (PostgreSQL) ```go