query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlterStmt

type AlterStmt struct {
	TableName    string
	NewTableName string
}

AlterStmt is a DSL that allows creating a full ALTER TABLE query.

func (AlterStmt) IsReadOnly

func (stmt AlterStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (AlterStmt) Run

func (stmt AlterStmt) Run(tx *database.Transaction, _ []expr.Param) (Result, error)

Run runs the ALTER TABLE statement in the given transaction. It implements the Statement interface.

type AlterTableAddField

type AlterTableAddField struct {
	TableName  string
	Constraint database.FieldConstraint
}

func (AlterTableAddField) IsReadOnly

func (stmt AlterTableAddField) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (AlterTableAddField) Run

Run runs the ALTER TABLE ADD FIELD statement in the given transaction. It implements the Statement interface.

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

func (stmt BeginStmt) Run(tx *database.Transaction, args []expr.Param) (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) Run

func (stmt CommitStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

type CreateIndexStmt

type CreateIndexStmt struct {
	IfNotExists bool
	Info        database.IndexInfo
}

CreateIndexStmt is a DSL that allows creating a full CREATE INDEX statement. It is typically created using the CreateIndex function.

func (CreateIndexStmt) IsReadOnly

func (stmt CreateIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (CreateIndexStmt) Run

func (stmt CreateIndexStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

Run runs the Create index statement in the given transaction. It implements the Statement interface.

type CreateTableStmt

type CreateTableStmt struct {
	IfNotExists bool
	Info        database.TableInfo
}

CreateTableStmt is a DSL that allows creating a full CREATE TABLE statement.

func (CreateTableStmt) IsReadOnly

func (stmt CreateTableStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (CreateTableStmt) Run

func (stmt CreateTableStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

Run runs the Create table statement in the given transaction. It implements the Statement interface.

type DropIndexStmt

type DropIndexStmt struct {
	IndexName string
	IfExists  bool
}

DropIndexStmt is a DSL that allows creating a DROP INDEX query.

func (DropIndexStmt) IsReadOnly

func (stmt DropIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (DropIndexStmt) Run

func (stmt DropIndexStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

Run runs the DropIndex statement in the given transaction. It implements the Statement interface.

type DropTableStmt

type DropTableStmt struct {
	TableName string
	IfExists  bool
}

DropTableStmt is a DSL that allows creating a DROP TABLE query.

func (DropTableStmt) IsReadOnly

func (stmt DropTableStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (DropTableStmt) Run

func (stmt DropTableStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

Run runs the DropTable statement in the given transaction. It implements the Statement interface.

type ExplainStmt

type ExplainStmt struct {
	Statement Statement
}

ExplainStmt is a Statement that displays information about how a statement is going to be executed, without executing it.

func (*ExplainStmt) IsReadOnly

func (s *ExplainStmt) IsReadOnly() bool

IsReadOnly indicates that this statement doesn't write anything into the database.

func (*ExplainStmt) Run

func (s *ExplainStmt) Run(tx *database.Transaction, params []expr.Param) (Result, error)

Run analyses the inner statement and displays its execution plan. If the statement is a stream, Optimize will be called prior to displaying all the operations. Explain currently only works on SELECT, UPDATE, INSERT and DELETE statements.

type Query

type Query struct {
	Statements []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) Query

New creates a new query with the given statements.

func (Query) Exec

func (q Query) Exec(tx *database.Transaction, args []expr.Param) (*Result, error)

Exec the query within the given transaction.

func (Query) Run

func (q Query) Run(ctx context.Context, db *database.Database, args []expr.Param) (*Result, error)

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

type ReIndexStmt

type ReIndexStmt struct {
	TableOrIndexName string
}

ReIndexStmt is a DSL that allows creating a full REINDEX statement.

func (ReIndexStmt) IsReadOnly

func (stmt ReIndexStmt) IsReadOnly() bool

IsReadOnly always returns false. It implements the Statement interface.

func (ReIndexStmt) Run

func (stmt ReIndexStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

Run runs the Reindex statement in the given transaction. It implements the Statement interface.

type Result

type Result struct {
	Iterator document.Iterator
	Tx       *database.Transaction
	// contains filtered or unexported fields
}

Result of a query.

func (*Result) Close

func (r *Result) Close() (err error)

Close the result stream. After closing the result, Stream is not supposed to be used. If the result stream was already closed, it returns ErrResultClosed.

func (*Result) Iterate

func (r *Result) Iterate(fn func(d document.Document) error) error

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

func (stmt RollbackStmt) Run(tx *database.Transaction, args []expr.Param) (Result, error)

type Statement

type Statement interface {
	Run(*database.Transaction, []expr.Param) (Result, error)
	IsReadOnly() bool
}

A Statement represents a unique action that can be executed against the database.

type StreamStmt

type StreamStmt struct {
	Stream   *stream.Stream
	ReadOnly bool
}

StreamStmt is a StreamStmt using a Stream.

func (*StreamStmt) IsReadOnly

func (s *StreamStmt) IsReadOnly() bool

IsReadOnly reports whether the stream will modify the database or only read it.

func (*StreamStmt) Run

func (s *StreamStmt) Run(tx *database.Transaction, params []expr.Param) (Result, error)

Run returns a result containing the stream. The stream will be executed by calling the Iterate method of the result.

func (*StreamStmt) String

func (s *StreamStmt) String() string

type StreamStmtIterator

type StreamStmtIterator struct {
	Stream *stream.Stream
	Tx     *database.Transaction
	Params []expr.Param
}

StreamStmtIterator iterates over a stream.

func (*StreamStmtIterator) Iterate

func (s *StreamStmtIterator) Iterate(fn func(d document.Document) error) error

Directories

Path Synopsis
Package glob implements wildcard pattern matching algorithms for strings.
Package glob implements wildcard pattern matching algorithms for strings.

Jump to

Keyboard shortcuts

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