sql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExist        = errors.New("exist")
	ErrNotExist     = errors.New("not exist")
	ErrNotSupported = errors.New("not supported")
	ErrInvalid      = errors.New("invalid")
	ErrNotEqual     = errors.New("not equal")
)

Functions

func NewCollectionWith

func NewCollectionWith(stmt *query.CreateTable) (document.Schema, error)

NewCollectionWith creates a new schema from the specified schema object.

func NewDataTypeFrom

func NewDataTypeFrom(elemType document.ElementType) (query.DataType, error)

func NewElementTypeFrom

func NewElementTypeFrom(sqlType query.DataType) (document.ElementType, error)

nolint: exhaustive

func NewElementWith

func NewElementWith(col *query.Column) (document.Element, error)

NewElementWith returns a new element with the specified column.

func NewIndexWith

func NewIndexWith(s document.Schema, def *query.Index) (document.Index, error)

NewIndexWith creates an index from the specified coulumn definition.

func NewKeyFromCond

func NewKeyFromCond(dbName string, schema document.Schema, cond *query.Condition) (store.Key, document.IndexType, error)

NewKeyFromCond returns a key for the specified condition.

func NewKeyFromIndex

func NewKeyFromIndex(dbName string, schema document.Schema, idx document.Index, objMap document.MapObject) (store.Key, error)

NewKeyFromIndex returns a key for the specified index.

func NewKeyFromObject

func NewKeyFromObject(dbName string, schema document.Schema, obj document.MapObject) (store.Key, error)

NewKeyFromObject returns a key from the specified object.

func NewKeyWith

func NewKeyWith(dbName string, tblName string, keyName string, val any) (store.Key, error)

NewKeyWith returns a key from the specified parameters.

func NewLimitWith

func NewLimitWith(limit *query.Limit) []store.Option

NewLimitWith returns a new store option with the specified limit option.

func NewObjectFromInsert

func NewObjectFromInsert(dbName string, schema document.Schema, stmt *query.Insert) (document.Key, document.MapObject, error)

NewObjectFromInsert returns a new object from the specified schema and columns.

func NewOrderWith

func NewOrderWith(orderBy *query.OrderBy) []store.Option

NewOrderWith returns a new store option with the specified orderby option.

func NewPrimaryIndexWith

func NewPrimaryIndexWith(elem document.Element) (document.Index, error)

NewPrimaryIndexWith creates an index from the specified element.

Types

type Conn

type Conn interface {
	Database() string
	Timestamp() time.Time
	SpanContext() tracer.Context
}

Conn represents a SQL connection.

type Service

type Service struct {
	*plugins.BaseService
}

Service represents a new SQL service instance.

func NewService

func NewService() *Service

NewService returns a new SQL service.

func (*Service) CancelTransactionWithError

func (service *Service) CancelTransactionWithError(ctx context.Context, txn store.Transaction, err error) error

CancelTransactionWithError cancels the specified transaction with the specified error.

func (*Service) CreateDatabase

func (service *Service) CreateDatabase(conn Conn, stmt *query.CreateDatabase) error

CreateDatabase handles a CREATE DATABASE query.

func (*Service) CreateIndex

func (service *Service) CreateIndex(conn Conn, stmt *query.CreateIndex) (message.Responses, error)

CreateIndex handles a CREATE INDEX query.

func (*Service) CreateTable

func (service *Service) CreateTable(conn Conn, stmt *query.CreateTable) error

CreateTable handles a CREATE TABLE query.

func (*Service) Delete

func (service *Service) Delete(conn Conn, stmt *query.Delete) (int, error)

Delete handles a DELETE query.

func (*Service) DeleteDocument

func (service *Service) DeleteDocument(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, docKey document.Key) error

DeleteDocument deletes the specified object.

func (*Service) DropDatabase

func (service *Service) DropDatabase(conn Conn, stmt *query.DropDatabase) error

DropDatabase handles a DROP DATABASE query.

func (*Service) DropTable

func (service *Service) DropTable(conn Conn, stmt *query.DropTable) error

DropIndex handles a DROP INDEX query.

func (*Service) Insert

func (service *Service) Insert(conn Conn, stmt *query.Insert) error

Insert handles a INSERT query.

func (*Service) InsertSecondaryIndexes

func (service *Service) InsertSecondaryIndexes(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, obj document.MapObject, prKey document.Key) error

InsertSecondaryIndexes inserts secondary indexes for the specified object.

func (*Service) RemoveSecondaryIndexes

func (service *Service) RemoveSecondaryIndexes(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, obj document.MapObject) error

RemoveSecondaryIndexes removes secondary indexes for the specified object.

func (*Service) Select

Select handles a SELECT query.

func (*Service) SelectDocumentObjects

func (service *Service) SelectDocumentObjects(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, cond *query.Condition, orderby *query.OrderBy, limit *query.Limit) (store.ResultSet, error)

SelectDatabaseObjects returns a result set of the specified database objects.

func (*Service) Update

func (service *Service) Update(conn Conn, stmt *query.Update) (int, error)

Update handles a UPDATE query.

func (*Service) UpdateDocument

func (service *Service) UpdateDocument(ctx context.Context, conn Conn, txn store.Transaction, schema document.Schema, obj any, updateCols query.ColumnList) error

UpdateDocument updates the specified object.

Jump to

Keyboard shortcuts

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