model

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const MigrationsTable = "`migrations`"

MigrationsTable is the name of the table in the DB.

View Source
const UserTable = "`user`"

UserTable is the name of the table in the DB.

Variables

View Source
var MigrationsFields = []string{"project", "filename", "statement_index", "status"}

MigrationsFields is a list of all columns in the DB table.

View Source
var MigrationsPrimaryFields = []string{"project", "filename"}

MigrationsPrimaryFields are the primary key fields in the DB table.

View Source
var UserFields = []string{"id", "name", "email"}

UserFields is a list of all columns in the DB table.

View Source
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) GetEmail

func (u *User) GetEmail() string

GetEmail will return the value of Email.

func (*User) GetID

func (u *User) GetID() string

GetID will return the value of ID.

func (*User) GetName

func (u *User) GetName() string

GetName will return the value of Name.

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) SetEmail

func (u *User) SetEmail(val string)

SetEmail sets Email to the provided value.

func (*User) SetID

func (u *User) SetID(val string)

SetID sets ID to the provided value.

func (*User) SetName

func (u *User) SetName(val string)

SetName sets Name to the provided value.

func (*User) Update

func (u *User) Update(opts ...QueryOption) string

Update starts building a UPDATE query.

Jump to

Keyboard shortcuts

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