query

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package query provides query building and parsing functionalities used by both MicroDB client and external users.

Package query provides query building and parsing functionalities used by both MicroDB client and external users.

Index

Constants

View Source
const (
	// QueryTypeSelect represents a SELECT statement.
	QueryTypeSelect = iota
	// QueryTypeInsert represents an INSERT or REPLACE statement.
	QueryTypeInsert
	// QueryTypeUpdate represents an UPDATE statement.
	QueryTypeUpdate
	// DestinationTypeLocal represents using local database as destination.
	DestinationTypeLocal
	// DestinationTypeOrigin represents using data origin as destination.
	DestinationTypeOrigin
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DestinationType

type DestinationType int

DestinationType represents the type of destination for the query.

type QueryStmt

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

QueryStmt represents a parsed query. nolint // Silence name suggestion.

func Query

func Query(query string) (*QueryStmt, error)

Query creates a new query statement.

This is used for chaining to provide access to MicroDB specific API through a conventitional builder interface.

func (*QueryStmt) GetDestinationTable

func (q *QueryStmt) GetDestinationTable() string

GetDestinationTable returns the destination table.

This is only used for INSERT queries.

func (*QueryStmt) GetDestinationType

func (q *QueryStmt) GetDestinationType() DestinationType

GetDestinationType returns the destination.

func (*QueryStmt) GetQueryType

func (q *QueryStmt) GetQueryType() QueryType

GetQueryType returns the query type.

func (*QueryStmt) GetRequiredTables

func (q *QueryStmt) GetRequiredTables() []string

GetRequiredTables returns all the tables required by the query.

func (*QueryStmt) OnLocal

func (q *QueryStmt) OnLocal() *QueryStmt

OnLocal forces the query to the local database.

This could be overrided at query-time if the query contains tables that do not exist locally.

func (*QueryStmt) OnOrigin

func (q *QueryStmt) OnOrigin() *QueryStmt

OnOrigin forces the query to the data origin.

func (*QueryStmt) SQL

func (q *QueryStmt) SQL() string

SQL converts the query into string format.

type QueryType

type QueryType int

QueryType represents the type of query. Currently, only SELECT, INSERT/REPLACE, and UPDATE is supported. nolint // Silence name suggestion.

Jump to

Keyboard shortcuts

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