querybuilder

package module
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2019 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(s string) string

Delete is functional delete

func QueryBuilder added in v0.2.0

func QueryBuilder(fns ...FString) string

QueryBuilder composes Or a functional query builder Example: QueryBuilder(Select("column1", "column2"), FTable("users"))

func StringMap added in v0.2.0

func StringMap(fn FString, ss ...string) []string

StringMap iterates over a slice of strings with a valid FString function type

Types

type ColumnMutator added in v0.2.1

type ColumnMutator func(fn FString) FString

ColumnMutator is a function type that defines a Mutator. In this case, Mutator is more akin to PRIMARY KEY and NOT NULL.

type FString added in v0.2.0

type FString func(s string) string

FString is a special function type for function composition

func AddForeignKey added in v0.4.2

func AddForeignKey(name, refer, ontable string) FString

AddForeignKey creates an AddForeignKey statement when altering a table

func AlterTable added in v0.4.2

func AlterTable(t string) FString

AlterTable starts the Alter Table statement

func And added in v0.2.0

func And(c, op string) FString

And inserts a where clause prefixed with "AND" It takes 2 arguments, the column and the operation, both as strings It returns a function suitable for composing

func AndEq added in v0.2.0

func AndEq(c string) FString

AndEq builds an OR clause with equals Helper function for And, which sets the operation to '='

func Boolean added in v0.2.1

func Boolean(name string) FString

Boolean creates a boolean type column

func CreateConstraint added in v0.4.1

func CreateConstraint(c string, fn FString) FString

CreateConstraint adds a constraint to the end of a line

func CreateTable added in v0.2.1

func CreateTable(name string) FString

CreateTable begins a new create table query

func DropConstraint added in v0.4.3

func DropConstraint(table, field, ctype string) FString

DropConstraint assists in drop constraints based on the format { table }_{ field }_{ constrainttype } Example: DropConstraint("roles", "user_id", "fkey")

func DropTable added in v0.2.1

func DropTable(t string) FString

DropTable builds a drop table query

func Field added in v0.2.1

func Field(name, field string) FString

Field creates a field with a given type

func ForeignKey added in v0.4.1

func ForeignKey(refer, ontable string, fn FString) FString

ForeignKey helps in defining foreignkey constraints

func From added in v0.2.0

func From(t string) FString

From adds a table value

func InnerJoin added in v0.3.1

func InnerJoin(t string) FString

InnerJoin assists in creating an inner join query

func Insert

func Insert(into string, columns ...string) FString

Insert is functional insert

func Int added in v0.2.1

func Int(name string) FString

Int creates a new serial type column

func NotNull added in v0.2.1

func NotNull(fn FString) FString

NotNull sets a field to Not Null

func On added in v0.3.1

func On(c1, c2 string) FString

On sets the constraints for Joins

func Or added in v0.2.0

func Or(c, op string) FString

Or inserts a where clause prefixed with "OR" It takes 2 arguments, the column and the operation, both as strings It returns a function suitable for composing

func OrEq added in v0.2.0

func OrEq(c string) FString

OrEq builds an OR clause with equals Helper function for Or, which sets the operation to '='

func Prepare added in v0.2.1

func Prepare(fn FString) FString

Prepare caches a generated string for reuse

func PrimaryKey added in v0.2.1

func PrimaryKey(fn FString) FString

PrimaryKey is a mutator that creates a primary key from a given string

func Real added in v0.2.1

func Real(name string) FString

Real creates a new serial type column

func Select

func Select(columns ...string) FString

Select is functional select

func Serial added in v0.2.1

func Serial(name string) FString

Serial creates a new serial type column

func Set added in v0.2.0

func Set(columns ...string) FString

Set builds a "set" clause

func SubQuery added in v0.3.1

func SubQuery(fns ...FString) FString

SubQuery inserts a subquery

func TimeStamp added in v0.2.1

func TimeStamp(name string) FString

TimeStamp inserts a timestamp column of the given name

func TimeStamps added in v0.2.1

func TimeStamps() FString

TimeStamps inserts a created_at and updated_at timestamp

func UUID added in v0.3.0

func UUID() FString

UUID create's a field called id with the UUID type

func Unique added in v0.4.1

func Unique(fn FString) FString

Unique sets a field to be Unique

func Update

func Update(table string) FString

Update is functional Update

func VarChar added in v0.2.1

func VarChar(name string, size int) FString

VarChar creates a varchar column of a given size

func Where added in v0.2.0

func Where(c, op string) FString

Where inserts a where clause It takes 2 arguments, the column and the operation, both as strings It returns a function suitable for composing

func WhereEq added in v0.2.0

func WhereEq(c string) FString

WhereEq set's a where clause Or equals Helper function for Where, which sets the operation to '='

func WhereInSub added in v0.4.4

func WhereInSub(c string, subquery FString) FString

WhereInSub builds an IN clause

func WithColumns added in v0.2.1

func WithColumns(fns ...FString) FString

WithColumns builds columns through function composition

func WithDefault added in v0.2.2

func WithDefault(fn FString, v string) FString

WithDefault adds a default value. Value must always be as a string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL