mgo

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: 14 Imported by: 0

Documentation

Index

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

func (m *Mongo) Batch(ctx context.Context, req *model.BatchRequest) ([]int64, error)

Batch performs the provided operations in a single Batch

func (*Mongo) Close

func (m *Mongo) Close() error

Close gracefully the Mongo client

func (*Mongo) Create

func (m *Mongo) Create(ctx context.Context, col string, req *model.CreateRequest) (int64, error)

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

func (*Mongo) CreateDatabaseIfNotExist

func (m *Mongo) CreateDatabaseIfNotExist(ctx context.Context, project string) error

CreateDatabaseIfNotExist creates a database if not exist which has same name of project

func (*Mongo) Delete

func (m *Mongo) Delete(ctx context.Context, col string, req *model.DeleteRequest) (int64, error)

Delete removes the document(s) from the database which match the condition

func (*Mongo) DeleteCollection

func (m *Mongo) DeleteCollection(ctx context.Context, col string) error

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

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

GetCollections returns collection / tables name of specified database

func (*Mongo) GetConnectionState

func (m *Mongo) GetConnectionState(ctx context.Context) bool

GetConnectionState : function to check connection state

func (*Mongo) GetDBType

func (m *Mongo) GetDBType() model.DBType

GetDBType returns the dbType of the crud block

func (*Mongo) IsClientSafe

func (m *Mongo) IsClientSafe(context.Context) error

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

func (m *Mongo) RawBatch(ctx context.Context, queries []string) error

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

func (m *Mongo) SetProjectAESKey(aesKey []byte)

SetProjectAESKey sets aes key

func (*Mongo) SetQueryFetchLimit

func (m *Mongo) SetQueryFetchLimit(limit int64)

SetQueryFetchLimit sets data fetch limit

func (*Mongo) Update

func (m *Mongo) Update(ctx context.Context, col string, req *model.UpdateRequest) (int64, error)

Update updates the document(s) which match the condition provided.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL