Documentation
¶
Index ¶
- Constants
- Variables
- type Migrations
- func (m *Migrations) Delete(opts ...QueryOption) string
- func (m *Migrations) GetFilename() string
- func (m *Migrations) GetProject() string
- func (m *Migrations) GetStatementIndex() int64
- func (m *Migrations) GetStatus() string
- func (m *Migrations) Insert(opts ...QueryOption) string
- func (m *Migrations) Select(opts ...QueryOption) string
- func (m *Migrations) SetFilename(val string)
- func (m *Migrations) SetProject(val string)
- func (m *Migrations) SetStatementIndex(val int64)
- func (m *Migrations) SetStatus(val string)
- func (m *Migrations) Update(opts ...QueryOption) string
- type QueryConfig
- func (q *QueryConfig) Apply(opts ...QueryOption) *QueryConfig
- func (q *QueryConfig) WithColumns(cols []string) QueryOption
- func (q *QueryConfig) WithLimit(start, offset int) QueryOption
- func (q *QueryConfig) WithOrderBy(clause string) QueryOption
- func (q *QueryConfig) WithStatement(stmt string) QueryOption
- func (q *QueryConfig) WithTable(name string) QueryOption
- func (q *QueryConfig) WithWhere(clause string) QueryOption
- type QueryOption
- type User
- func (u *User) Delete(opts ...QueryOption) string
- func (u *User) GetEmail() string
- func (u *User) GetID() string
- func (u *User) GetName() string
- func (u *User) Insert(opts ...QueryOption) string
- func (u *User) Select(opts ...QueryOption) string
- func (u *User) SetEmail(val string)
- func (u *User) SetID(val string)
- func (u *User) SetName(val string)
- func (u *User) Update(opts ...QueryOption) string
Constants ¶
const MigrationsTable = "`migrations`"
MigrationsTable is the name of the table in the DB.
const UserTable = "`user`"
UserTable is the name of the table in the DB.
Variables ¶
var MigrationsFields = []string{"project", "filename", "statement_index", "status"}
MigrationsFields is a list of all columns in the DB table.
var MigrationsPrimaryFields = []string{"project", "filename"}
MigrationsPrimaryFields are the primary key fields in the DB table.
var UserFields = []string{"id", "name", "email"}
UserFields is a list of all columns in the DB table.
var UserPrimaryFields = []string{"id"}
UserPrimaryFields are the primary key fields in the DB table.
Functions ¶
This section is empty.
Types ¶
type Migrations ¶
type Migrations struct {
// Project
Project string `db:"project" json:"project"`
// Filename
Filename string `db:"filename" json:"filename"`
// Statement Index
StatementIndex int64 `db:"statement_index" json:"statement_index"`
// Status
Status string `db:"status" json:"status"`
}
Migrations generated for db table `migrations`.
func (*Migrations) Delete ¶
func (m *Migrations) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*Migrations) GetFilename ¶
func (m *Migrations) GetFilename() string
GetFilename will return the value of Filename.
func (*Migrations) GetProject ¶
func (m *Migrations) GetProject() string
GetProject will return the value of Project.
func (*Migrations) GetStatementIndex ¶
func (m *Migrations) GetStatementIndex() int64
GetStatementIndex will return the value of StatementIndex.
func (*Migrations) GetStatus ¶
func (m *Migrations) GetStatus() string
GetStatus will return the value of Status.
func (*Migrations) Insert ¶
func (m *Migrations) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*Migrations) Select ¶
func (m *Migrations) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*Migrations) SetFilename ¶
func (m *Migrations) SetFilename(val string)
SetFilename sets Filename to the provided value.
func (*Migrations) SetProject ¶
func (m *Migrations) SetProject(val string)
SetProject sets Project to the provided value.
func (*Migrations) SetStatementIndex ¶
func (m *Migrations) SetStatementIndex(val int64)
SetStatementIndex sets StatementIndex to the provided value.
func (*Migrations) SetStatus ¶
func (m *Migrations) SetStatus(val string)
SetStatus sets Status to the provided value.
func (*Migrations) Update ¶
func (m *Migrations) Update(opts ...QueryOption) string
Update starts building a UPDATE query.
type QueryConfig ¶
type QueryConfig struct {
Table string
Columns []string
Where string
OrderBy string
LimitStart int
LimitOffset int
Statement string
}
QueryConfig is a function-chaining SQL statement type.
func (*QueryConfig) Apply ¶
func (q *QueryConfig) Apply(opts ...QueryOption) *QueryConfig
Apply will use passed query options to populate the query.
func (*QueryConfig) WithColumns ¶
func (q *QueryConfig) WithColumns(cols []string) QueryOption
WithColumns will set the columns to use for the query.
func (*QueryConfig) WithLimit ¶
func (q *QueryConfig) WithLimit(start, offset int) QueryOption
WithLimit will set the limit clause parameters for the query.
func (*QueryConfig) WithOrderBy ¶
func (q *QueryConfig) WithOrderBy(clause string) QueryOption
WithOrderBy will set the order by clause for the query.
func (*QueryConfig) WithStatement ¶
func (q *QueryConfig) WithStatement(stmt string) QueryOption
WithStatement will change the statement for the query.
func (*QueryConfig) WithTable ¶
func (q *QueryConfig) WithTable(name string) QueryOption
WithTable will set the table name for the query.
func (*QueryConfig) WithWhere ¶
func (q *QueryConfig) WithWhere(clause string) QueryOption
WithWhere will set the where condition for the query.
type QueryOption ¶
type QueryOption interface {
WithTable(name string) QueryOption
WithColumns(cols []string) QueryOption
WithWhere(clause string) QueryOption
WithOrderBy(clause string) QueryOption
WithLimit(start, offset int) QueryOption
WithStatement(stmt string) QueryOption
}
QueryOption is implemented by each data model type.
func WithColumns ¶
func WithColumns(cols []string) QueryOption
WithColumns will set the columns to use for the query.
func WithLimit ¶
func WithLimit(start, offset int) QueryOption
WithLimit will set the limit clause parameters for the query.
func WithOrderBy ¶
func WithOrderBy(clause string) QueryOption
WithOrderBy will set the order by clause for the query.
func WithStatement ¶
func WithStatement(stmt string) QueryOption
WithStatement will change the statement for the query.
func WithTable ¶
func WithTable(name string) QueryOption
WithTable will set the table name for the query.
func WithWhere ¶
func WithWhere(clause string) QueryOption
WithWhere will set the where condition for the query.
type User ¶
type User struct {
// ID
ID string `db:"id" json:"id"`
// Name
Name string `db:"name" json:"name"`
// Email
Email string `db:"email" json:"email"`
}
User generated for db table `user`.
func (*User) Delete ¶
func (u *User) Delete(opts ...QueryOption) string
Delete starts building a DELETE query.
func (*User) Insert ¶
func (u *User) Insert(opts ...QueryOption) string
Insert starts building an INSERT INTO query.
func (*User) Select ¶
func (u *User) Select(opts ...QueryOption) string
Select starts building a SELECT query.
func (*User) Update ¶
func (u *User) Update(opts ...QueryOption) string
Update starts building a UPDATE query.