sql

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 17 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 utils.DBType, enabled, removeProjectScope bool, connection string) (s *SQL, err error)

Init initialises a new sql instance

func (*SQL) Aggregate

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

Aggregate performs a mongo db pipeline aggregation

func (*SQL) Batch

func (s *SQL) Batch(ctx context.Context, project string, txRequest *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, project, col string, req *model.CreateRequest) (int64, error)

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

func (*SQL) CreateProjectIfNotExist added in v0.15.0

func (s *SQL) CreateProjectIfNotExist(ctx context.Context, project string) error

CreateProjectIfNotExist creates a schema / database

func (*SQL) Delete

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

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

func (*SQL) DeleteCollection added in v0.13.0

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

DeleteCollection drops a table

func (*SQL) DescribeTable added in v0.12.0

func (s *SQL) DescribeTable(ctx context.Context, project, col string) ([]utils.FieldType, []utils.ForeignKeysType, []utils.IndexType, error)

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

func (*SQL) GetCollections added in v0.12.0

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

GetCollections returns collection / tables name of specified database

func (*SQL) GetConnectionState added in v0.13.0

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

GetConnectionState : Function to get connection state

func (*SQL) GetDBType

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

GetDBType returns the dbType of the crud block

func (*SQL) IsClientSafe added in v0.12.0

func (s *SQL) IsClientSafe() error

IsClientSafe checks whether database is enabled and connected

func (*SQL) RawBatch added in v0.12.0

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) RawExec added in v0.12.0

func (s *SQL) RawExec(ctx context.Context, query string) error

RawExec performs an operation for schema creation NOTE: not to be exposed externally

func (*SQL) Read

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

Read query document(s) from the database

func (*SQL) Update

func (s *SQL) Update(ctx context.Context, project, 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