Documentation ¶
Index ¶
- type Crud
- type Module
- func (m *Module) Aggregate(ctx context.Context, dbAlias, project, col string, req *model.AggregateRequest) (interface{}, error)
- func (m *Module) Batch(ctx context.Context, dbAlias, project string, req *model.BatchRequest) error
- func (m *Module) Create(ctx context.Context, dbAlias, project, col string, req *model.CreateRequest) error
- func (m *Module) CreateProjectIfNotExists(ctx context.Context, project, dbAlias string) error
- func (m *Module) Delete(ctx context.Context, dbAlias, project, col string, req *model.DeleteRequest) error
- func (m *Module) DeleteTable(ctx context.Context, project, dbAlias, col string) error
- func (m *Module) DescribeTable(ctx context.Context, dbAlias, project, col string) ([]utils.FieldType, []utils.ForeignKeysType, []utils.IndexType, error)
- func (m *Module) GetCollections(ctx context.Context, project, dbAlias string) ([]utils.DatabaseCollections, error)
- func (m *Module) GetConnectionState(ctx context.Context, dbAlias string) bool
- func (m *Module) GetDBType(dbAlias string) (string, error)
- func (m *Module) InternalCreate(ctx context.Context, dbAlias, project, col string, req *model.CreateRequest) error
- func (m *Module) InternalDelete(ctx context.Context, dbAlias, project, col string, req *model.DeleteRequest) error
- func (m *Module) InternalUpdate(ctx context.Context, dbAlias, project, col string, req *model.UpdateRequest) error
- func (m *Module) RawBatch(ctx context.Context, dbAlias string, batchedQueries []string) error
- func (m *Module) Read(ctx context.Context, dbAlias, project, col string, req *model.ReadRequest) (interface{}, error)
- func (m *Module) SetConfig(project string, crud config.Crud) error
- func (m *Module) SetHooks(hooks *model.CrudHooks, metricHook model.MetricCrudHook)
- func (m *Module) Update(ctx context.Context, dbAlias, project, col string, req *model.UpdateRequest) error
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 ¶
Module is the root block providing convenient wrappers
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) 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
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
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
GetConnectionState gets the current state of client
func (*Module) GetDBType ¶ added in v0.15.0
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) 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