query

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeginStmt

type BeginStmt struct {
	Writable bool
}

BeginStmt is a statement that creates a new transaction.

func (BeginStmt) IsReadOnly

func (stmt BeginStmt) IsReadOnly() bool

func (BeginStmt) Prepare

func (stmt BeginStmt) Prepare(*statement.Context) (statement.Statement, error)

Prepare implements the Preparer interface.

func (BeginStmt) Run

func (stmt BeginStmt) Run(ctx *statement.Context) (statement.Result, error)

type CommitStmt

type CommitStmt struct{}

CommitStmt is a statement that commits the current active transaction.

func (CommitStmt) IsReadOnly

func (stmt CommitStmt) IsReadOnly() bool

func (CommitStmt) Prepare

Prepare implements the Preparer interface.

func (CommitStmt) Run

func (stmt CommitStmt) Run(ctx *statement.Context) (statement.Result, error)

type Context

type Context struct {
	Ctx    context.Context
	DB     *database.Database
	Tx     *database.Transaction
	Params []environment.Param
}

func (*Context) GetTx

func (c *Context) GetTx() *database.Transaction

type Query

type Query struct {
	Statements []statement.Statement
	// contains filtered or unexported fields
}

A Query can execute statements against the database. It can read or write data from any table, or even alter the structure of the database. Results are returned as streams.

func New

func New(statements ...statement.Statement) Query

New creates a new query with the given statements.

func (*Query) Prepare

func (q *Query) Prepare(context *Context) error

Prepare the statements by calling their Prepare methods. It stops at the first statement that doesn't implement the statement.Preparer interface.

func (Query) Run

func (q Query) Run(context *Context) (*statement.Result, error)

Run executes all the statements in their own transaction and returns the last result.

type RollbackStmt

type RollbackStmt struct{}

RollbackStmt is a statement that rollbacks the current active transaction.

func (RollbackStmt) IsReadOnly

func (stmt RollbackStmt) IsReadOnly() bool

func (RollbackStmt) Prepare

Prepare implements the Preparer interface.

func (RollbackStmt) Run

func (stmt RollbackStmt) Run(ctx *statement.Context) (statement.Result, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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