crud

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crud

type Crud interface {
	Create(ctx context.Context, project, col string, req *model.CreateRequest) (int64, error)
	Read(ctx context.Context, project, col string, req *model.ReadRequest) (int64, interface{}, error)
	Update(ctx context.Context, project, col string, req *model.UpdateRequest) (int64, error)
	Delete(ctx context.Context, project, col string, req *model.DeleteRequest) (int64, error)
	Aggregate(ctx context.Context, project, col string, req *model.AggregateRequest) (interface{}, error)
	Batch(ctx context.Context, project string, req *model.BatchRequest) ([]int64, error)
	DescribeTable(ctc context.Context, project, col string) ([]utils.FieldType, []utils.ForeignKeysType, []utils.IndexType, error)
	RawExec(ctx context.Context, project string) error
	GetCollections(ctx context.Context, project string) ([]utils.DatabaseCollections, error)
	DeleteCollection(ctx context.Context, project, col string) error
	CreateProjectIfNotExist(ctx context.Context, project string) error
	RawBatch(ctx context.Context, batchedQueries []string) error
	GetDBType() utils.DBType
	IsClientSafe() error
	Close() error
	GetConnectionState(ctx context.Context) bool
}

Crud abstracts the implementation crud operations of databases

type Module

type Module struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Module is the root block providing convenient wrappers

func Init

func Init(removeProjectScope bool) *Module

Init create a new instance of the Module object

func (*Module) Aggregate

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

Aggregate performs an aggregation defined via the pipeline

func (*Module) Batch

func (m *Module) Batch(ctx context.Context, dbAlias, project string, req *model.BatchRequest) error

Batch performs a batch operation on the database

func (*Module) Create

func (m *Module) Create(ctx context.Context, dbAlias, project, col string, req *model.CreateRequest) error

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

func (*Module) CreateProjectIfNotExists added in v0.12.0

func (m *Module) CreateProjectIfNotExists(ctx context.Context, project, dbAlias string) error

GetCollections returns collection / tables name of specified database

func (*Module) Delete

func (m *Module) Delete(ctx context.Context, dbAlias, project, col string, req *model.DeleteRequest) error

Delete removes the document(s) which match a query from the database based on dbType

func (*Module) DeleteTable added in v0.13.0

func (m *Module) DeleteTable(ctx context.Context, project, dbAlias, col string) error

DeleteTable drop specified table from database

func (*Module) DescribeTable added in v0.12.0

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

DescribeTable performs a db operation for describing a table

func (*Module) GetCollections added in v0.12.0

func (m *Module) GetCollections(ctx context.Context, project, dbAlias string) ([]utils.DatabaseCollections, error)

GetCollections returns collection / tables name of specified database

func (*Module) GetConnectionState added in v0.13.0

func (m *Module) GetConnectionState(ctx context.Context, dbAlias string) bool

GetConnectionState gets the current state of client

func (*Module) GetDBType added in v0.15.0

func (m *Module) GetDBType(dbAlias string) (string, error)

GetDBType returns the type of the db for the alias provided

func (*Module) InternalCreate added in v0.12.0

func (m *Module) InternalCreate(ctx context.Context, dbAlias, project, col string, req *model.CreateRequest) error

InternalCreate inserts a document (or multiple when op is "all") into the database based on dbAlias. It does not invoke any hooks. This should only be used by the eventing module.

func (*Module) InternalDelete added in v0.12.0

func (m *Module) InternalDelete(ctx context.Context, dbAlias, project, col string, req *model.DeleteRequest) error

InternalDelete removes the document(s) which match a query from the database based on dbType. It does not invoke any hooks. This should only be used by the eventing module.

func (*Module) InternalUpdate added in v0.12.0

func (m *Module) InternalUpdate(ctx context.Context, dbAlias, project, col string, req *model.UpdateRequest) error

InternalUpdate updates the document(s) which match a query from the database based on dbType. It does not invoke any hooks. This should only be used by the eventing module.

func (*Module) RawBatch added in v0.12.0

func (m *Module) RawBatch(ctx context.Context, dbAlias string, batchedQueries []string) error

RawBatch performs a db operaion for schema creation

func (*Module) Read

func (m *Module) Read(ctx context.Context, dbAlias, project, col string, req *model.ReadRequest) (interface{}, error)

Read returns the document(s) which match a query from the database based on dbType

func (*Module) SetConfig

func (m *Module) SetConfig(project string, crud config.Crud) error

SetConfig set the rules and secret key required by the crud block

func (*Module) SetHooks added in v0.12.0

func (m *Module) SetHooks(hooks *model.CrudHooks, metricHook model.MetricCrudHook)

SetHooks sets the internal hooks

func (*Module) Update

func (m *Module) Update(ctx context.Context, dbAlias, project, col string, req *model.UpdateRequest) error

Update updates the document(s) which match a query from the database based on dbType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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