mongo

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID)

func DeleteMany

func DeleteMany(ctx context.Context, collection *mongo.Collection, ids []string)

func Install

func Install(config *ConfigEntity) (*mongo.Database, error)

func SoftDelete

func SoftDelete(ctx context.Context, collection *mongo.Collection, id primitive.ObjectID)

func SoftDeleteMany

func SoftDeleteMany(ctx context.Context, collection *mongo.Collection, ids []string)

func StrIdToObjectId

func StrIdToObjectId(ids []string) []primitive.ObjectID

func WithPagingFilter added in v0.1.0

func WithPagingFilter(page, size uint64, option *options.FindOptions)

func WithTimerFilter added in v0.1.0

func WithTimerFilter(start, end string, option *bson.D)

Types

type ConfigEntity

type ConfigEntity struct {
	Tls TLSEntity `json:"tls" bson:"tls" yaml:"tls" mapstructure:"tls"`

	Account  string `json:"account" bson:"account" yaml:"account" mapstructure:"account"`
	Password string `json:"password" bson:"password" yaml:"password" mapstructure:"password"`

	Address  string `json:"address" yaml:"address" mapstructure:"address"`
	Database string `json:"database" yaml:"database" mapstructure:"database"`

	Mode bool `json:"mode" yaml:"mode" mapstructure:"mode"` // Mode is true cluster

	MaxOpenConnects int `json:"max_open_connects" bson:"max_open_connects" yaml:"max_open_connects" mapstructure:"max_open_connects"`
	MaxIdleConnects int `json:"max_idle_connects" bson:"max_idle_connects" yaml:"max_idle_connects" mapstructure:"max_idle_connects"`
	ConnMaxLifeTime int `json:"conn_max_life_time" bson:"conn_max_life_time" yaml:"conn_max_life_time" mapstructure:"conn_max_life_time"`

	LoggerEnable bool `json:"logger_enable" bson:"logger_enable" yaml:"logger_enable" mapstructure:"logger_enable"`
	// contains filtered or unexported fields
}

func (*ConfigEntity) WithLoggerConsole added in v0.2.4

func (config *ConfigEntity) WithLoggerConsole(state bool)

func (*ConfigEntity) WithLoggerHandle added in v0.2.4

func (config *ConfigEntity) WithLoggerHandle(handle func(b []byte))

type TLSEntity

type TLSEntity struct {
	CaCert        string `json:"ca_cert" bson:"ca_cert" yaml:"ca_cert" mapstructure:"ca_cert"`
	ClientCert    string `json:"client_cert" bson:"client_cert" yaml:"client_cert" mapstructure:"client_cert"`
	ClientCertKey string `json:"client_cert_key" bson:"client_cert_key" yaml:"client_cert_key" mapstructure:"client_cert_key"`
}

type TableEntity

type TableEntity struct {
	ID        primitive.ObjectID `json:"id" bson:"_id"`
	CreatedAt time.Time          `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time          `json:"updated_at" bson:"updated_at"`
	DeletedAt *time.Time         `json:"deleted_at" bson:"deleted_at,omitempty"`
}

func (*TableEntity) BeforeInset

func (table *TableEntity) BeforeInset()

func (*TableEntity) BeforeUpdate

func (table *TableEntity) BeforeUpdate()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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