crud

package
v0.0.0-...-260b785 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 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 Crud

type Crud interface {
	Create(ctx context.Context, col string, req *model.CreateRequest) (int64, error)
	Read(ctx context.Context, col string, req *model.ReadRequest) (int64, interface{}, map[string]map[string]string, *model.SQLMetaData, error)
	Update(ctx context.Context, col string, req *model.UpdateRequest) (int64, error)
	Delete(ctx context.Context, col string, req *model.DeleteRequest) (int64, error)
	Aggregate(ctx context.Context, col string, req *model.AggregateRequest) (interface{}, error)
	Batch(ctx context.Context, req *model.BatchRequest) ([]int64, error)
	DescribeTable(ctc context.Context, col string) ([]model.InspectorFieldType, []model.IndexType, error)
	RawQuery(ctx context.Context, query string, isDebug bool, args []interface{}) (int64, interface{}, *model.SQLMetaData, error)
	GetCollections(ctx context.Context) ([]utils.DatabaseCollections, error)
	DeleteCollection(ctx context.Context, col string) error
	CreateDatabaseIfNotExist(ctx context.Context, name string) error
	RawBatch(ctx context.Context, batchedQueries []string) error
	GetDBType() model.DBType
	IsClientSafe(ctx context.Context) error
	IsSame(conn, dbName string, driverConf config.DriverConfig) bool
	Close() error
	GetConnectionState(ctx context.Context) bool
	SetQueryFetchLimit(limit int64)
	SetProjectAESKey(aesKey []byte)
}

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, dbAlias, col string, req *model.AggregateRequest, params model.RequestParams) (interface{}, error)

Aggregate performs an aggregation defined via the pipeline

func (*Module) Batch

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

Batch performs a batch operation on the database

func (*Module) CloseConfig

func (m *Module) CloseConfig() error

CloseConfig close the rules and secret key required by the crud block

func (*Module) Create

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

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

func (*Module) Delete

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

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

func (*Module) DeleteTable

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

DeleteTable drop specified table from database

func (*Module) DescribeTable

func (m *Module) DescribeTable(ctx context.Context, dbAlias, col string) ([]model.InspectorFieldType, []model.IndexType, error)

DescribeTable performs a db operation for describing a table

func (*Module) ExecPreparedQuery

func (m *Module) ExecPreparedQuery(ctx context.Context, dbAlias, id string, req *model.PreparedQueryRequest, params model.RequestParams) (interface{}, *model.SQLMetaData, error)

ExecPreparedQuery executes PreparedQueries request

func (*Module) GetCollections

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

GetCollections returns collection / tables name of specified database

func (*Module) GetConnectionState

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

GetConnectionState gets the current state of client

func (*Module) GetDBType

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

GetDBType returns the type of the db for the alias provided

func (*Module) GetSchema

func (m *Module) GetSchema(dbAlias, col string) (model.Fields, bool)

GetSchema function gets schema

func (*Module) InternalCreate

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

InternalCreate inserts a documents (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

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

InternalDelete removes the documents(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

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

InternalUpdate updates the documents(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) IsPreparedQueryPresent

func (m *Module) IsPreparedQueryPresent(dbAlias, id string) bool

IsPreparedQueryPresent checks if id exist

func (*Module) RawBatch

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

RawBatch performs a db operation for schema creation

func (*Module) Read

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

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

func (*Module) SetAdminManager

func (m *Module) SetAdminManager(a *admin.Manager)

SetAdminManager sets the admin manager

func (*Module) SetCachingModule

func (m *Module) SetCachingModule(c cachingInterface)

SetCachingModule sets caching module

func (*Module) SetConfig

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

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

func (*Module) SetGetSecrets

func (m *Module) SetGetSecrets(function utils.GetSecrets)

SetGetSecrets sets the GetSecrets function

func (*Module) SetHooks

func (m *Module) SetHooks(metricHook model.MetricCrudHook)

SetHooks sets the internal hooks

func (*Module) SetIntegrationManager

func (m *Module) SetIntegrationManager(i integrationManagerInterface)

SetIntegrationManager sets the integration manager

func (*Module) SetPreparedQueryConfig

func (m *Module) SetPreparedQueryConfig(ctx context.Context, prepQueries config.DatabasePreparedQueries) error

SetPreparedQueryConfig set prepared query config of crud module

func (*Module) SetProjectAESKey

func (m *Module) SetProjectAESKey(aesKey string) error

SetProjectAESKey set aes config for sql databases

func (*Module) SetSchemaConfig

func (m *Module) SetSchemaConfig(ctx context.Context, schemaDoc model.Type, schemas config.DatabaseSchemas) error

SetSchemaConfig set schema config of crud module

func (*Module) Update

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

Update updates the documents(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