Documentation ¶
Index ¶
- type Mongo
- func (m *Mongo) Aggregate(ctx context.Context, col string, req *model.AggregateRequest) (interface{}, error)
- func (m *Mongo) Batch(ctx context.Context, req *model.BatchRequest) ([]int64, error)
- func (m *Mongo) Close() error
- func (m *Mongo) Create(ctx context.Context, col string, req *model.CreateRequest) (int64, error)
- func (m *Mongo) CreateDatabaseIfNotExist(ctx context.Context, project string) error
- func (m *Mongo) Delete(ctx context.Context, col string, req *model.DeleteRequest) (int64, error)
- func (m *Mongo) DeleteCollection(ctx context.Context, col string) error
- func (m *Mongo) DescribeTable(ctc context.Context, col string) ([]model.InspectorFieldType, []model.IndexType, error)
- func (m *Mongo) GetCollections(ctx context.Context) ([]utils.DatabaseCollections, error)
- func (m *Mongo) GetConnectionState(ctx context.Context) bool
- func (m *Mongo) GetDBType() model.DBType
- func (m *Mongo) IsClientSafe(context.Context) error
- func (m *Mongo) IsSame(conn, dbName string, driverConf config.DriverConfig) bool
- func (m *Mongo) RawBatch(ctx context.Context, queries []string) error
- func (m *Mongo) RawQuery(ctx context.Context, query string, isDebug bool, args []interface{}) (int64, interface{}, *model.SQLMetaData, error)
- func (m *Mongo) Read(ctx context.Context, col string, req *model.ReadRequest) (int64, interface{}, map[string]map[string]string, *model.SQLMetaData, error)
- func (m *Mongo) SetProjectAESKey(aesKey []byte)
- func (m *Mongo) SetQueryFetchLimit(limit int64)
- func (m *Mongo) Update(ctx context.Context, col string, req *model.UpdateRequest) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
Mongo holds the mongo session
func Init ¶
func Init(enabled bool, connection, dbName string, driverConf config.DriverConfig) (mongoStub *Mongo, err error)
Init initialises a new mongo instance
func (*Mongo) Aggregate ¶
func (m *Mongo) Aggregate(ctx context.Context, col string, req *model.AggregateRequest) (interface{}, error)
Aggregate performs a mongo db pipeline aggregation
func (*Mongo) CreateDatabaseIfNotExist ¶
CreateDatabaseIfNotExist creates a database if not exist which has same name of project
func (*Mongo) DeleteCollection ¶
DeleteCollection removes a collection from database`
func (*Mongo) DescribeTable ¶
func (m *Mongo) DescribeTable(ctc context.Context, col string) ([]model.InspectorFieldType, []model.IndexType, error)
DescribeTable return a structure of sql table
func (*Mongo) GetCollections ¶
GetCollections returns collection / tables name of specified database
func (*Mongo) GetConnectionState ¶
GetConnectionState : function to check connection state
func (*Mongo) IsClientSafe ¶
IsClientSafe checks whether database is enabled and connected
func (*Mongo) IsSame ¶
func (m *Mongo) IsSame(conn, dbName string, driverConf config.DriverConfig) bool
IsSame checks if we've got the same connection string
func (*Mongo) RawBatch ¶
RawBatch performs a batch operation for schema creation NOTE: not to be exposed externally
func (*Mongo) RawQuery ¶
func (m *Mongo) RawQuery(ctx context.Context, query string, isDebug bool, args []interface{}) (int64, interface{}, *model.SQLMetaData, error)
RawQuery query document(s) from the database
func (*Mongo) Read ¶
func (m *Mongo) Read(ctx context.Context, col string, req *model.ReadRequest) (int64, interface{}, map[string]map[string]string, *model.SQLMetaData, error)
Read queries document(s) from the database
func (*Mongo) SetProjectAESKey ¶
SetProjectAESKey sets aes key
func (*Mongo) SetQueryFetchLimit ¶
SetQueryFetchLimit sets data fetch limit