mgo

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 11 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 string) (mongoStub *Mongo, err error)

Init initialises a new mongo instance

func (*Mongo) Aggregate

func (m *Mongo) Aggregate(ctx context.Context, project, col string, req *model.AggregateRequest) (interface{}, error)

Aggregate performs a mongo db pipeline aggregation

func (*Mongo) Batch

func (m *Mongo) Batch(ctx context.Context, project string, txRequest *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, project, col string, req *model.CreateRequest) (int64, error)

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

func (*Mongo) CreateProjectIfNotExist added in v0.15.0

func (s *Mongo) CreateProjectIfNotExist(ctx context.Context, project string) error

func (*Mongo) Delete

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

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

func (Mongo) DeleteCollection added in v0.13.0

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

DeleteCollection removes a collection from database`

func (*Mongo) DescribeTable added in v0.12.0

func (m *Mongo) DescribeTable(ctx context.Context, project, col string) ([]utils.FieldType, []utils.ForeignKeysType, []utils.IndexType, error)

DescribeTable return a structure of sql table

func (*Mongo) GetCollections added in v0.12.0

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

GetCollections returns collection / tables name of specified database

func (*Mongo) GetConnectionState added in v0.13.0

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

GetConnectionState : function to check connection state

func (*Mongo) GetDBType

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

GetDBAlias returns the dbType of the crud block

func (*Mongo) IsClientSafe added in v0.12.0

func (m *Mongo) IsClientSafe() error

IsClientSafe checks whether database is enabled and connected

func (*Mongo) RawBatch added in v0.12.0

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) RawExec added in v0.12.0

func (m *Mongo) RawExec(ctx context.Context, query string) error

RawExec performs an operation for schema creation NOTE: not to be exposed externally

func (*Mongo) Read

func (m *Mongo) Read(ctx context.Context, project, col string, req *model.ReadRequest) (int64, interface{}, error)

Read querys document(s) from the database

func (*Mongo) Update

func (m *Mongo) Update(ctx context.Context, project, 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