sql

package
v0.0.0-...-260b785 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQL

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

SQL holds the sql db object

func Init

func Init(dbType model.DBType, enabled bool, connection string, dbName string, driverConf config.DriverConfig) (s *SQL, err error)

Init initialises a new sql instance

func (*SQL) Aggregate

func (s *SQL) Aggregate(ctx context.Context, col string, req *model.AggregateRequest) (interface{}, error)

Aggregate performs a mongo db pipeline aggregation

func (*SQL) Batch

func (s *SQL) Batch(ctx context.Context, req *model.BatchRequest) ([]int64, error)

Batch performs the provided operations in a single Batch

func (*SQL) Close

func (s *SQL) Close() error

Close gracefully the SQL client

func (*SQL) Create

func (s *SQL) Create(ctx context.Context, col string, req *model.CreateRequest) (int64, error)

Create inserts a document (or multiple when op is "all") into the database

func (*SQL) CreateDatabaseIfNotExist

func (s *SQL) CreateDatabaseIfNotExist(ctx context.Context, name string) error

CreateDatabaseIfNotExist creates a schema / database

func (*SQL) Delete

func (s *SQL) Delete(ctx context.Context, col string, req *model.DeleteRequest) (int64, error)

Delete removes the document(s) from the database which match the condition

func (*SQL) DeleteCollection

func (s *SQL) DeleteCollection(ctx context.Context, col string) error

DeleteCollection drops a table

func (*SQL) DescribeTable

func (s *SQL) DescribeTable(ctx context.Context, col string) ([]model.InspectorFieldType, []model.IndexType, error)

DescribeTable return a description of sql table & foreign keys in table NOTE: not to be exposed externally

func (*SQL) GetCollections

func (s *SQL) GetCollections(ctx context.Context) ([]utils.DatabaseCollections, error)

GetCollections returns collection / tables name of specified database

func (*SQL) GetConnectionState

func (s *SQL) GetConnectionState(ctx context.Context) bool

GetConnectionState : function to check connection state

func (*SQL) GetDBType

func (s *SQL) GetDBType() model.DBType

GetDBType returns the dbType of the crud block

func (*SQL) IsClientSafe

func (s *SQL) IsClientSafe(ctx context.Context) error

IsClientSafe checks whether database is enabled and connected

func (*SQL) IsSame

func (s *SQL) IsSame(conn, dbName string, driverConf config.DriverConfig) bool

IsSame checks if we've got the same connection string

func (*SQL) RawBatch

func (s *SQL) RawBatch(ctx context.Context, queries []string) error

RawBatch performs a batch operation for schema creation NOTE: not to be exposed externally

func (*SQL) RawQuery

func (s *SQL) RawQuery(ctx context.Context, query string, isDebug bool, args []interface{}) (int64, interface{}, *model.SQLMetaData, error)

RawQuery query document(s) from the database

func (*SQL) Read

func (s *SQL) Read(ctx context.Context, col string, req *model.ReadRequest) (int64, interface{}, map[string]map[string]string, *model.SQLMetaData, error)

Read query document(s) from the database

func (*SQL) SetProjectAESKey

func (s *SQL) SetProjectAESKey(aesKey []byte)

SetProjectAESKey sets aes key

func (*SQL) SetQueryFetchLimit

func (s *SQL) SetQueryFetchLimit(limit int64)

SetQueryFetchLimit sets data fetch limit

func (*SQL) Update

func (s *SQL) Update(ctx context.Context, col string, req *model.UpdateRequest) (int64, error)

Update updates the document(s) which match the condition provided.

Jump to

Keyboard shortcuts

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