sql

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

nolint:gocognit

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 NewAlterAddIndexSchemaWith added in v1.0.3

func NewAlterAddIndexSchemaWith(schema document.Schema, addIndex *query.Index) (document.Schema, error)

NewAlterAddColumnSchemaWith creates a new schema with the specified alter index.

func NewDocumentElementFrom added in v1.0.2

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

NewDocumentElementFrom returns a new element with the specified column.

func NewDocumentElementTypeFrom added in v1.0.2

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

NewDocumentElementFrom returns a new element with the specified column.

func NewDocumentIndexFrom added in v1.0.2

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

NewDocumentIndexFrom creates an index from the specified coulumn definition.

func NewDocumentIndexTypeFrom added in v1.0.3

func NewDocumentIndexTypeFrom(idxType query.IndexType) (document.IndexType, error)

NewDocumentIndexTypeFrom creates an index type from the specified element.

func NewDocumentKeyForSchema added in v1.0.2

func NewDocumentKeyForSchema(dbName string, schema document.Schema, colName string, colVal any) (document.Key, error)

NewDocumentKeyForSchema returns a key for the specified schema.

func NewDocumentKeyFromCond added in v1.0.2

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

NewDocumentKeyFromCond returns a key for the specified condition.

func NewDocumentKeyFromIndex added in v1.0.2

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

NewDocumentKeyFromIndex returns a key for the specified index.

func NewDocumentKeyFromObject added in v1.0.2

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

NewDocumentKeyFromObject returns a key from the specified object.

func NewDocumentObjectFromInsert added in v1.0.2

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

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

func NewDocumentPrimaryIndexFrom added in v1.0.2

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

NewDocumentPrimaryIndexFrom creates an index from the specified element.

func NewDocumentSchemaFrom added in v1.0.2

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

NewDocumentSchemaFrom creates a new schema from the specified schema object.

func NewLimitWith

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

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

func NewOrderWith

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

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

func NewQueryColumnFrom added in v1.0.2

func NewQueryColumnFrom(elem document.Element) (*query.Column, error)

NewQueryColumnFrom returns a new column with the specified element.

func NewQueryDataTypeFrom added in v1.0.2

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

NewQueryDataTypeFrom returns a new column with the specified element.

func NewQuerySchemaFrom added in v1.0.2

func NewQuerySchemaFrom(doc document.Schema) (*query.Schema, error)

NewQuerySchemaFrom creates a new schema from the specified schema object.

func NewRowFrom added in v1.0.2

func NewRowFrom(obj document.Object) (query.Row, error)

NewRowFrom creates a new row from the specified object.

Types

type Conn

type Conn interface {
	// Database returns the database.
	Database() string
	// Timestamp returns the timestamp.
	Timestamp() time.Time
	// UUID returns the UUID.
	UUID() uuid.UUID
	// SpanContext returns the span context.
	SpanContext() tracer.Context
}

Conn represents a SQL connection.

type ConnectionMap added in v1.1.0

type ConnectionMap map[string]DatabaseMap

ConnectionMap represents a connection map.

func NewConnectionMap added in v1.1.0

func NewConnectionMap() ConnectionMap

NewConnection returns a new connection.

func (ConnectionMap) GetTransaction added in v1.1.0

func (connMap ConnectionMap) GetTransaction(conn Conn, db store.Database) (store.Transaction, error)

GetTransaction returns the transaction.

func (ConnectionMap) RemoveTransaction added in v1.1.0

func (connMap ConnectionMap) RemoveTransaction(conn Conn, db store.Database) error

RemoveTransaction removes the transaction.

func (ConnectionMap) SetTransaction added in v1.1.0

func (connMap ConnectionMap) SetTransaction(conn Conn, db store.Database, txn store.Transaction) error

SetTransaction sets the transaction.

type Database added in v1.1.0

type Database struct {
	store.Transaction
}

Database represents a database.

type DatabaseMap added in v1.1.0

type DatabaseMap map[string]*Database

DatabaseMap represents a database map.

func NewDatabaseMap added in v1.1.0

func NewDatabaseMap() DatabaseMap

NewDatabase returns a new database.

type Service

type Service struct {
	*plugins.BaseService
	ConnectionMap
}

Service represents a new SQL service instance.

func NewService

func NewService() *Service

NewService returns a new SQL service.

func (*Service) AlterDatabase added in v1.0.3

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

AlterDatabase handles a ALTER DATABASE query.

func (*Service) AlterTable added in v1.0.3

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

AlterTable handles a ALTER TABLE query.

func (*Service) Begin added in v1.1.0

func (service *Service) Begin(conn Conn) error

Begin handles a BEGIN query.

func (*Service) CancelTransaction added in v1.1.0

func (service *Service) CancelTransaction(ctx context.Context, conn Conn, db store.Database, txn store.Transaction) error

CancelTransaction cancels the specified transaction.

func (*Service) CancelTransactionWithError

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

CancelTransactionWithError cancels the specified transaction with the specified error.

func (*Service) Commit added in v1.1.0

func (service *Service) Commit(conn Conn) error

Commit handles a COMMIT query.

func (*Service) CommitTransaction added in v1.1.0

func (service *Service) CommitTransaction(ctx context.Context, conn Conn, db store.Database, txn store.Transaction) error

CommitTransaction commits the specified transaction.

func (*Service) CreateDatabase

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

CreateDatabase handles a CREATE DATABASE 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) Rollback added in v1.1.0

func (service *Service) Rollback(conn Conn) error

Rollback handles a ROLLBACK query.

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) Transact added in v1.1.0

func (service *Service) Transact(conn Conn, db store.Database, write bool) (store.Transaction, error)

Transact returns a transaction object.

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