mongo

package
v5.6.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCustomBsonRegistry

func NewCustomBsonRegistry() *bsoncodec.Registry

Types

type BaseMongoDocument

type BaseMongoDocument struct {
	CreatedAt *time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	UpdatedAt *time.Time `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"`
	CreatedBy *string    `json:"createdBy,omitempty" bson:"createdBy,omitempty"`
	UpdatedBy *string    `json:"updatedBy,omitempty" bson:"updatedBy,omitempty"`
}

func (*BaseMongoDocument) SetCreateParam

func (b *BaseMongoDocument) SetCreateParam(actionBy string)

func (*BaseMongoDocument) SetUpdateParam

func (b *BaseMongoDocument) SetUpdateParam(actionBy string)

type BaseMongoModel

type BaseMongoModel struct {
	ID                 *primitive.ObjectID `json:"-" bson:"_id,omitempty"`
	*BaseMongoDocument `bson:",inline"`
}

func (*BaseMongoModel) SetCreateParam

func (b *BaseMongoModel) SetCreateParam(actionBy string)

func (*BaseMongoModel) SetUpdateParam

func (b *BaseMongoModel) SetUpdateParam(actionBy string)

type Collection

type Collection struct {
	*mongo.Collection
	// contains filtered or unexported fields
}

type Config

type Config struct {
	ConnectionString string
	EnableLog        bool
	ModuleName       string
}

type Database

type Database struct {
	*mongo.Database
	// contains filtered or unexported fields
}

func (*Database) Collection

func (d *Database) Collection(name string, opts ...*options.CollectionOptions) *Collection

type Mongo

type Mongo struct {
	*mongo.Client
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, logger log.Log, opts ...*options.ClientOptions) (*Mongo, error)

func NewWithAWSRoleAuth

func NewWithAWSRoleAuth(ctx context.Context, serviceName string, logger log.Log, c Config, t Tracer, opts ...*options.ClientOptions) (*Mongo, error)

func NewWithDefaultOptions added in v5.1.3

func NewWithDefaultOptions(ctx context.Context, serviceName string, logger log.Log, c Config, t Tracer, opts ...*options.ClientOptions) (*Mongo, error)

func (*Mongo) Database

func (m *Mongo) Database(name string, opts ...*options.DatabaseOptions) *Database

func (*Mongo) GetClient

func (m *Mongo) GetClient() *mongo.Client

func (*Mongo) GetLogger

func (m *Mongo) GetLogger() log.Log

func (*Mongo) HealthCheck

func (m *Mongo) HealthCheck(ctx context.Context) error

func (*Mongo) Name

func (m *Mongo) Name(ctx context.Context) string

func (*Mongo) Shutdown

func (m *Mongo) Shutdown(ctx context.Context) error

type MongoLogger

type MongoLogger struct {
	// contains filtered or unexported fields
}

func (*MongoLogger) Error

func (m *MongoLogger) Error(err error, message string, keysAndValues ...interface{})

func (*MongoLogger) Info

func (m *MongoLogger) Info(level int, message string, keysAndValues ...interface{})

func (*MongoLogger) PoolEvent

func (m *MongoLogger) PoolEvent(e *event.PoolEvent)

type Tracer

type Tracer interface {
	MongoDB() *event.CommandMonitor
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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