statements

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddColumnStatement

type AddColumnStatement struct {
	// contains filtered or unexported fields
}

AddColumnStatement statement used to add a column to a table

func NewAddColumnStatement

func NewAddColumnStatement(connection *sql.DB, connectioninfo connection.IConnectionInfo, model *models.EntityModel, column *models.ColumnDescriptor) *AddColumnStatement

NewAddColumnStatement creates a new AddColumnStatement

**Parameters**

  • connection: connection used to execute sql statement
  • connectioninfo: driver specific connection info
  • model: model for which to create index
  • column: column to add to the table

**Returns**

  • *AddColumnStatement: statement used to prepare operation

func (*AddColumnStatement) Prepare

func (statement *AddColumnStatement) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • *PreparedStatement: operation used to execute statement

type AddUnique

type AddUnique struct {
	// contains filtered or unexported fields
}

AddUnique statement which adds a unique index to a table

func NewAddUnique

func NewAddUnique(connection *sql.DB, connectioninfo connection.IConnectionInfo, model *models.EntityModel, unique *models.IndexDescriptor) *AddUnique

NewAddUnique creates a new AddUnique statement

**Parameters**

  • connection: connection used to execute sql statement
  • connectioninfo: driver specific connection info
  • model: model for which to create index
  • unique: unique index to add

**Returns**

  • *AddUnique: statement used to prepare operation

func (*AddUnique) Prepare

func (statement *AddUnique) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • *PreparedStatement: operation used to execute statement

type CreateIndexStatement

type CreateIndexStatement struct {
	// contains filtered or unexported fields
}

CreateIndexStatement statement used to prepare an operation used to create an index

func NewCreateIndexStatement

func NewCreateIndexStatement(model *models.EntityModel, index *models.IndexDescriptor, connection *sql.DB, connectioninfo connection.IConnectionInfo) *CreateIndexStatement

NewCreateIndexStatement creates a new CreateIndexStatement

**Parameters**

  • model: model for which to create index
  • index: index to create
  • connection: connection used to execute sql statement
  • connectioninfo: driver specific connection info

**Returns**

-*CreateIndexStatement: statement used to prepare operation

func (*CreateIndexStatement) Prepare

func (statement *CreateIndexStatement) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • *PreparedStatement: operation used to execute statement

type CreateStatement

type CreateStatement struct {
	// contains filtered or unexported fields
}

CreateStatement statement used to create tables for models in database

func NewCreateStatement

func NewCreateStatement(model *models.EntityModel, connection *sql.DB, connectioninfo connection.IConnectionInfo) *CreateStatement

NewCreateStatement creates a new create statement

**Parameters**

  • model: model representing entity for which to create a new table
  • connection: connection to database
  • connectioninfo: driver specific connection info

**Returns**

  • CreateStatement: statement used to prepare create operation

func (*CreateStatement) Prepare

func (statement *CreateStatement) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • PreparedStatement: statement to use to create table

type DeleteStatement

type DeleteStatement struct {
	// contains filtered or unexported fields
}

DeleteStatement statement used to delete entity data from the database

func NewDeleteStatement

func NewDeleteStatement(model *models.EntityModel, connection *sql.DB, connectioninfo connection.IConnectionInfo) *DeleteStatement

NewDeleteStatement creates a statement used to delete entities from a database

**Parameters**

  • model: model of entity of which to delete rows
  • connection: connection used to send sql statements
  • connectioninfo: driver specific database information

**Returns**

  • DeleteStatement: statement to use to prepare operation

func (*DeleteStatement) Prepare

func (statement *DeleteStatement) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • PreparedStatement: statement used to execute command

func (*DeleteStatement) Where

func (statement *DeleteStatement) Where(predicate interface{}) *DeleteStatement

Where adds a predicate used to filter for data to delete

**Parameters**

  • predicate: predicate expression specifying data to delete

**Returns**

  • DeleteStatement: current statement for fluent behavior

type DropIndex

type DropIndex struct {
	// contains filtered or unexported fields
}

DropIndex statement which removes an index from the database

func NewDropIndex

func NewDropIndex(connection *sql.DB, connectioninfo connection.IConnectionInfo, model *models.EntityModel, name string) *DropIndex

NewDropIndex creates a new DropIndex statement

**Parameters**

  • connection: connection used to execute sql statement
  • connectioninfo: driver specific connection info
  • model: model for which to create index
  • name: name of index to drop

**Returns**

  • *DropIndex: statement used to prepare operation

func (*DropIndex) Prepare

func (statement *DropIndex) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • *PreparedStatement: operation used to execute statement

type DropTable

type DropTable struct {
	// contains filtered or unexported fields
}

DropTable statement to remove a table in a database

func NewDropTable

func NewDropTable(connection *sql.DB, connectioninfo connection.IConnectionInfo, name string) *DropTable

NewDropTable creates a new DropTable statement

**Parameters**

  • connection: connection to use to execute statement
  • connectioninfo: driver specific connection info
  • name: name of table to remove

**Returns**

  • *DropTable: statement to use to prepare operation

func (*DropTable) Prepare

func (statement *DropTable) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • *PreparedStatement: prepared operation to execute

type InsertLoad

type InsertLoad struct {
	// contains filtered or unexported fields
}

InsertLoad - statement used to insert data into a database table

func NewInsertLoad

func NewInsertLoad(model *models.EntityModel, connection *sql.DB, connectioninfo connection.IConnectionInfo) *InsertLoad

NewInsertLoad - creates a new statement used to insert data to a database table

func (*InsertLoad) Columns

func (statement *InsertLoad) Columns(columns ...*models.ColumnDescriptor) *InsertLoad

Columns specifies fields to fill from existing column descriptors

**Parameters**

  • columns: columns to fill

**Returns**

  • InsertLoad: this statement for fluent behavior

func (*InsertLoad) Fields

func (statement *InsertLoad) Fields(fieldnames ...string) *InsertLoad

Fields specify fields to fill

**Parameters**

  • `fieldnames`: names of field to insert. Remember that you have to specify at least all fields which don't map to columns having an autoincrement or default value

**Returns**

  • InsertLoad: this statement for fluent behavior

func (*InsertLoad) Load

func (statement *InsertLoad) Load(load *LoadStatement) *InsertLoad

Load specifies the load statement used to insert data into the table

**Parameters**

  • load: statement used to load data to insert

**Returns**

  • *InsertLoad: this statement for fluent behavior

func (*InsertLoad) Prepare

func (statement *InsertLoad) Prepare() *PreparedStatement

Prepare prepares the insert statement for execution

**Returns** - `PreparedStatement`: Statement to execute

type InsertStatement

type InsertStatement struct {
	// contains filtered or unexported fields
}

InsertStatement - statement used to insert data into a database table

func NewInsertStatement

func NewInsertStatement(model *models.EntityModel, connection *sql.DB, connectioninfo connection.IConnectionInfo) *InsertStatement

NewInsertStatement - creates a new statement used to insert data to a database table

func (*InsertStatement) Columns

func (statement *InsertStatement) Columns(fieldnames ...string) *InsertStatement

Columns specify columns to fill

**Parameters**

  • `fieldnames`: names of field to insert. Remember that you have to specify at least all fields which don't map to columns having an autoincrement or default value

**Returns**

  • `InsertStatement`: this statement for fluent behavior

func (*InsertStatement) Prepare

func (statement *InsertStatement) Prepare() *PreparedStatement

Prepare prepares the insert statement for execution

**Returns** - `PreparedStatement`: Statement to execute

func (*InsertStatement) ReturnID added in v0.1.5

func (statement *InsertStatement) ReturnID() *InsertStatement

ReturnID specified that statement should return identity of inserted row

**Returns**

  • *InsertStatement: this statement for fluent behavior

func (*InsertStatement) Values added in v0.1.5

func (statement *InsertStatement) Values(values ...interface{}) *InsertStatement

Values specifies value expressions to use for statement

**Parameters**

  • values: collection of expressions to use to build statement values

**Returns**

  • *InsertStatement: this statement for fluent behavior

type JoinType added in v0.1.3

type JoinType int8

JoinType specified the type of join to apply

const (
	// JoinTypeInner specifies an INNER JOIN operation
	JoinTypeInner JoinType = iota
)

type LoadStatement

type LoadStatement struct {
	// contains filtered or unexported fields
}

LoadStatement statement used to load data from the database

func NewLoadStatement

func NewLoadStatement(connection *sql.DB, connectioninfo connection.IConnectionInfo) *LoadStatement

NewLoadStatement creates a new statement used to load data from the database

**Parameters**

  • model: model of entity of which to load data
  • connection: connection used to send sql statements
  • connectioninfo: driver specific database information

**Returns**

  • LoadStatement: statement to use to prepare operation

func (*LoadStatement) Alias added in v0.2.0

func (statement *LoadStatement) Alias(alias string) *LoadStatement

Alias set an alias to use when loading from the table

mainly used to prevent conflicts with joined tables

func (*LoadStatement) Columns

func (statement *LoadStatement) Columns(columns []*models.ColumnDescriptor) *LoadStatement

Columns specifies columns to load

**Parameters**

  • columns: columns to load in result set

**Returns**

  • LoadStatement: this statement for fluent behavior

func (*LoadStatement) Fields

func (statement *LoadStatement) Fields(fields ...interface{}) *LoadStatement

Fields set fields to load from database

**Parameters**

  • fields: field expressions for data to load

**Returns**

  • LoadStatement: this statement for fluent behavior

func (*LoadStatement) From added in v0.2.0

func (statement *LoadStatement) From(from interface{}) *LoadStatement

From - specifies a data set to load results from

**Parameters**

  • from: data to select result from

**Returns**

  • *LoadStatement: this statement for fluent behavior

func (*LoadStatement) GroupBy added in v0.1.5

func (statement *LoadStatement) GroupBy(fields ...interface{}) *LoadStatement

GroupBy set criterias for result grouping

**Parameters**

  • fields: expression which specifies fields to group by

**Returns**

  • *LoadStatement: this statement for fluent behavior

func (*LoadStatement) Join added in v0.2.0

func (statement *LoadStatement) Join(jointype JoinType, table string, predicate interface{}, alias string) *LoadStatement

Join adds a join operation to apply to the load statement

func (*LoadStatement) Model added in v0.2.0

func (statement *LoadStatement) Model(model *models.EntityModel) *LoadStatement

Model - specifies a model to base SELECT on

**Parameters**

  • model: model for which to load data

**Returns**

  • LoadStatement: this statement for fluent behavior

func (*LoadStatement) Prepare

func (statement *LoadStatement) Prepare() *PreparedLoadStatement

Prepare prepares the load statement for execution

**Returns**

  • PreparedLoadStatement: statement to be used to load data

func (*LoadStatement) Table added in v0.1.5

func (statement *LoadStatement) Table(table string) *LoadStatement

Table specifies a table to load data from

**Parameters**

  • table: table to load data from

**Returns**

  • LoadStatement: this statement for fluent behavior

func (*LoadStatement) Union added in v0.2.0

func (statement *LoadStatement) Union(load *PreparedLoadStatement, all bool) *LoadStatement

Union - concatenates another result set to a result

func (*LoadStatement) Where

func (statement *LoadStatement) Where(predicate interface{}) *LoadStatement

Where set predicate for data to match

**Parameters**

  • predicate: predicate expression specifying filter

**Returns**

  • LoadStatement: this statement for fluent behavior

type PreparedLoadStatement

type PreparedLoadStatement struct {
	// contains filtered or unexported fields
}

PreparedLoadStatement statement used to load data from the database

func (*PreparedLoadStatement) Command added in v0.1.5

func (statement *PreparedLoadStatement) Command() string

Command sql command string sent to database

**Returns**

  • string: sql-command

func (*PreparedLoadStatement) Execute

func (statement *PreparedLoadStatement) Execute(arguments ...interface{}) (*sql.Rows, error)

Execute executes the statement and returns the result rows

**Parameters**

  • arguments: arguments used to fill statement parameters

**Returns**

  • Rows: result rows
  • error: error if statement could not get executed

func (*PreparedLoadStatement) ExecuteEntity added in v0.2.0

func (statement *PreparedLoadStatement) ExecuteEntity(arguments ...interface{}) ([]interface{}, error)

ExecuteEntity - loads matching entity data from database

func (*PreparedLoadStatement) ExecuteEntityTransaction added in v0.2.0

func (statement *PreparedLoadStatement) ExecuteEntityTransaction(transaction *sql.Tx, arguments ...interface{}) ([]interface{}, error)

ExecuteEntityTransaction - loads matching entity data from database

func (*PreparedLoadStatement) ExecuteMappedEntity added in v0.2.0

func (statement *PreparedLoadStatement) ExecuteMappedEntity(model *models.EntityModel, arguments ...interface{}) ([]interface{}, error)

ExecuteMappedEntity - loads matching entity data from database

func (*PreparedLoadStatement) ExecuteMappedEntityTransaction added in v0.2.0

func (statement *PreparedLoadStatement) ExecuteMappedEntityTransaction(transaction *sql.Tx, model *models.EntityModel, arguments ...interface{}) ([]interface{}, error)

ExecuteMappedEntityTransaction - loads matching entity data from database

func (*PreparedLoadStatement) ExecuteScalar

func (statement *PreparedLoadStatement) ExecuteScalar(arguments ...interface{}) (interface{}, error)

ExecuteScalar executes the statement and returns one value as result. This means the statement should return exactly one column.

Multiple rows are supported however.

**Parameters**

  • arguments: arguments used to fill statement parameters

**Returns**

  • interface{}: result scalar
  • error: error if statement could not get executed

func (*PreparedLoadStatement) ExecuteScalarTransaction added in v0.1.5

func (statement *PreparedLoadStatement) ExecuteScalarTransaction(transaction *sql.Tx, arguments ...interface{}) (interface{}, error)

ExecuteScalarTransaction executes the statement and returns one value as result. This means the statement should return exactly one column.

Multiple rows are supported however.

**Parameters**

  • arguments: arguments used to fill statement parameters

**Returns**

  • interface{}: result scalar
  • error: error if statement could not get executed

func (*PreparedLoadStatement) ExecuteSet

func (statement *PreparedLoadStatement) ExecuteSet(arguments ...interface{}) ([]interface{}, error)

ExecuteSet executes the statement and returns a set of result values. This means the statement should return a set of rows with exactly one column

**Parameters**

  • arguments: arguments used to fill statement parameters

**Returns**

  • []interface{}: result set
  • error: error if statement could not get executed

func (*PreparedLoadStatement) ExecuteSetTransaction added in v0.1.5

func (statement *PreparedLoadStatement) ExecuteSetTransaction(transaction *sql.Tx, arguments ...interface{}) ([]interface{}, error)

ExecuteSetTransaction executes the statement and returns a set of result values. This means the statement should return a set of rows with exactly one column

**Parameters**

  • arguments: arguments used to fill statement parameters

**Returns**

  • []interface{}: result set
  • error: error if statement could not get executed

func (*PreparedLoadStatement) ExecuteTransaction added in v0.1.5

func (statement *PreparedLoadStatement) ExecuteTransaction(transaction *sql.Tx, arguments ...interface{}) (*sql.Rows, error)

ExecuteTransaction executes the statement and returns the result rows

**Parameters**

  • arguments: arguments used to fill statement parameters

**Returns**

  • Rows: result rows
  • error: error if statement could not get executed

type PreparedStatement

type PreparedStatement struct {
	// contains filtered or unexported fields
}

PreparedStatement - statement containing a prepared command to be executed

func (*PreparedStatement) Command

func (statement *PreparedStatement) Command() string

Command sql command string send to database

**Returns**

  • string: sql-command

func (*PreparedStatement) Execute

func (statement *PreparedStatement) Execute(arguments ...interface{}) (int64, error)

Execute executes the statement

**Parameters**

  • arguments: parameter values for statement

**Returns**

  • int64: number of affected rows
  • error: error if any occured

func (*PreparedStatement) ExecuteTransaction

func (statement *PreparedStatement) ExecuteTransaction(transaction *sql.Tx, arguments ...interface{}) (int64, error)

ExecuteTransaction executes the statement using a transaction

**Parameters**

  • transaction: transaction used to execute statement
  • arguments: parameter values for statement

**Returns**

  • int64: number of affected rows
  • error: error if any occured

type RenameTable

type RenameTable struct {
	// contains filtered or unexported fields
}

RenameTable statement used to rename a table in a database

func NewRenameTable

func NewRenameTable(connection *sql.DB, connectioninfo connection.IConnectionInfo, oldname string, newname string) *RenameTable

NewRenameTable creates a new RenameTable statement

**Parameters**

  • connection: connection to use to execute statement
  • connectioninfo: driver specific connection info
  • oldname: current name of table
  • newname: name to rename table to

**Returns**

  • *RenameTable: statement to use to prepare operation

func (*RenameTable) Prepare

func (statement *RenameTable) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • *PreparedStatement: prepared operation to execute

type UpdateStatement

type UpdateStatement struct {
	// contains filtered or unexported fields
}

UpdateStatement statement used to update data in a database

func NewUpdateStatement

func NewUpdateStatement(model *models.EntityModel, connection *sql.DB, connectioninfo connection.IConnectionInfo) *UpdateStatement

NewUpdateStatement creates a statement used to update entities of a database

**Parameters**

  • model: model of entity of which to update rows
  • connection: connection used to send sql statements
  • connectioninfo: driver specific database information

**Returns**

  • UpdateStatement: statement to use to prepare operation

func (*UpdateStatement) Prepare

func (statement *UpdateStatement) Prepare() *PreparedStatement

Prepare prepares the statement for execution

**Returns**

  • PreparedStatement: statement used to execute command

func (*UpdateStatement) Set

func (statement *UpdateStatement) Set(operations ...interface{}) *UpdateStatement

Set specifies update operations for statement

**Parameters**

  • operations: expressions specifying update operations

**Returns**

  • UpdateStatement: current statement for fluent behavior

func (*UpdateStatement) Where

func (statement *UpdateStatement) Where(predicate interface{}) *UpdateStatement

Where adds a predicate used to filter for data to update

**Parameters**

  • predicate: predicate expression specifying filter for data to update

**Returns**

  • UpdateStatement: current statement for fluent behavior

Jump to

Keyboard shortcuts

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