crud

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: Apache-2.0 Imports: 8 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) error
	Read(ctx context.Context, project, col string, req *model.ReadRequest) (interface{}, error)
	Update(ctx context.Context, project, col string, req *model.UpdateRequest) error
	Delete(ctx context.Context, project, col string, req *model.DeleteRequest) error
	Aggregate(ctx context.Context, project, col string, req *model.AggregateRequest) (interface{}, error)
	Batch(ctx context.Context, project string, req *model.BatchRequest) error
	DescribeTable(ctc context.Context, project, dbType, col string) ([]utils.FieldType, []utils.ForeignKeysType, error)
	RawExec(ctx context.Context, project string) error
	GetCollections(ctx context.Context, project string) ([]utils.DatabaseCollections, error)
	RawBatch(ctx context.Context, batchedQueries []string) error
	GetDBType() utils.DBType
	IsClientSafe() error
	Close() error
}

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() *Module

Init create a new instance of the Module object

func (*Module) Aggregate

func (m *Module) Aggregate(ctx context.Context, dbType, 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, dbType, project string, req *model.BatchRequest) error

Batch performs a batch operation on the database

func (*Module) Create

func (m *Module) Create(ctx context.Context, dbType, 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, dbType string) error

GetCollections returns collection / tables name of specified database

func (*Module) Delete

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

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

func (*Module) DescribeTable added in v0.12.0

func (m *Module) DescribeTable(ctx context.Context, dbType, project, col string) ([]utils.FieldType, []utils.ForeignKeysType, 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, dbType string) ([]utils.DatabaseCollections, error)

GetCollections returns collection / tables name of specified database

func (*Module) InternalCreate added in v0.12.0

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

InternalCreate inserts a document (or multiple when op is "all") into the database based on dbType. 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, dbType, 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, dbType, 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, dbType string, batchedQueries []string) error

RawBatch performs a db operaion for schema creation

func (*Module) Read

func (m *Module) Read(ctx context.Context, dbType, 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(crud config.Crud) error

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

func (*Module) SetHooks added in v0.12.0

func (m *Module) SetHooks(hooks *model.CrudHooks)

SetHooks sets the internal hooks

func (*Module) Update

func (m *Module) Update(ctx context.Context, dbType, 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