crud

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 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
	GetDBType() utils.DBType
	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

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

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) 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) GetPrimaryDB

func (m *Module) GetPrimaryDB() (Crud, error)

GetPrimaryDB get the database configured as primary

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) 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