sMongo

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetID

func GetID(id interface{}) primitive.ObjectID

func GetIDs

func GetIDs(objs []mgm.DefaultModel) []primitive.ObjectID

func GetIdsFilter

func GetIdsFilter(ids []string) bson.D

GetIdsFilter

func GetTsFilter

func GetTsFilter(tsFrom, tsTo int64) bson.D

GetTsFilter, $gte: tsFrom $lt: tsTo

Types

type Client added in v0.5.8

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

type ClientsMap added in v0.5.8

type ClientsMap map[string]*Client

type CollManager added in v0.3.6

type CollManager struct {
	Collection
	// contains filtered or unexported fields
}

func Coll added in v0.3.6

func Coll(env, connection, database, collection, interval string) CollManager

func (*CollManager) Agregates added in v0.3.6

func (c *CollManager) Agregates(docs interface{}) error

func (*CollManager) Count added in v0.3.6

func (c *CollManager) Count() (int64, error)

func (*CollManager) Drop added in v0.5.7

func (c *CollManager) Drop() error

func (*CollManager) Filters added in v0.3.6

func (c *CollManager) Filters(f Filters) *CollManager

func (*CollManager) Find added in v0.3.6

func (c *CollManager) Find(objs interface{}) error

func (*CollManager) FindOne added in v0.3.6

func (c *CollManager) FindOne(obj mgm.Model) error

func (*CollManager) Limit added in v0.3.6

func (c *CollManager) Limit(l int64) *CollManager

func (*CollManager) Pipeline added in v0.3.6

func (c *CollManager) Pipeline(p mongo.Pipeline) *CollManager

func (*CollManager) Sorts added in v0.3.6

func (c *CollManager) Sorts(s Sorts) *CollManager

type Collection

type Collection struct {
	Connection *ConnectionParams
	Database   *mongo.Database
	Collection *mgm.Collection
}

func New

func New(env, connection, database, collection, interval string) *Collection

New

func (*Collection) Agregates

func (c *Collection) Agregates(pipeline mongo.Pipeline, docs interface{}) error

func (*Collection) AgregatesCount

func (c *Collection) AgregatesCount(pipeline mongo.Pipeline) ([]bson.M, error)

func (*Collection) AgregatesCountWithCtx

func (c *Collection) AgregatesCountWithCtx(ctx context.Context, pipeline mongo.Pipeline) ([]bson.M, error)

func (*Collection) AgregatesWithCtx

func (c *Collection) AgregatesWithCtx(ctx context.Context, pipeline mongo.Pipeline, docs interface{}) error

func (*Collection) Clone

func (c *Collection) Clone(name string) *Collection

Clone, create Connection to a new collection in the same DB

func (*Collection) Count

func (c *Collection) Count(filter interface{}, opts *options.CountOptions) (int64, error)

Count

func (*Collection) Create

func (c *Collection) Create(obj mgm.Model) bool

Create

func (*Collection) CreateIndex

func (c *Collection) CreateIndex(fields interface{}, unique bool)

CreateIndex, create an index for a specific field in a collectionName

func (*Collection) CreateIndexes added in v0.3.1

func (c *Collection) CreateIndexes(indexes Indexes)

func (*Collection) CreateMany

func (c *Collection) CreateMany(docs []mgm.Model) bool

CreateMany

func (*Collection) Drop added in v0.5.7

func (c *Collection) Drop() error

func (*Collection) Find

func (c *Collection) Find(filters interface{}, opts *options.FindOptions, objs interface{}) error

Find

func (*Collection) FindById

func (c *Collection) FindById(id interface{}, obj mgm.Model) error

FindById

func (*Collection) FindOne

func (c *Collection) FindOne(filters interface{}, opts options.FindOneOptions, obj mgm.Model) error

FindOne

func (*Collection) First

func (c *Collection) First(tsFrom, tsTo int64, obj mgm.Model) error

First, $gte: tsFrom $lt: tsTo, tsFrom = tsTo = 0 for "ts" first object,

func (*Collection) FirstTs

func (c *Collection) FirstTs(tsFrom, tsTo int64) int64

Last, $gte: tsFrom $lt: tsTo, tsFrom = tsTo = 0 for first

func (*Collection) Last

func (c *Collection) Last(tsFrom, tsTo int64, obj mgm.Model) error

Last, $gte: tsFrom $lt: tsTo, tsFrom = tsTo = 0 for "ts" Last object,

func (*Collection) LastTs

func (c *Collection) LastTs(tsFrom, tsTo int64) int64

Last, $gte: tsFrom $lt: tsTo, tsFrom = tsTo = 0 for last

func (*Collection) Update

func (c *Collection) Update(obj mgm.Model) bool

Update

func (*Collection) Upsert added in v0.4.1

func (c *Collection) Upsert(obj mgm.Model, field string) bool

Upsert

type CollectionsMap added in v0.5.8

type CollectionsMap map[string]*CollManager

type Colls added in v0.5.4

type Colls map[string]CollManager

func NewColls added in v0.5.4

func NewColls() Colls

func (Colls) Get added in v0.5.4

func (colls Colls) Get(env, connection, database, collection, interval string, indexes Indexes) CollManager

type ConnectionParams

type ConnectionParams struct {
	Environment      string `yaml: "environment"`
	Username         string `yaml: "username"`
	Password         string `yaml: "password"`
	Host             string `yaml: "host"`
	Port             string `yaml: "port"`
	AuthDatabase     string `yaml: "authdatabase"`
	Tls              bool   `yaml: "tls"`
	Protocol         string `yaml: "protocol"`
	AuthMechanism    string `yaml: "authmechanism"`
	ReadPreference   string `yaml: "readpreference"`
	DirectConnection bool   `yaml: "directconnection"`
}

ConnectionParams, Databases access data

type Database added in v0.5.8

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

type DatabasesMap added in v0.5.8

type DatabasesMap map[string]*Database

type Filters added in v0.3.5

type Filters struct {
	Fields bson.D
}

func Filter added in v0.3.6

func Filter() *Filters

func (*Filters) Append added in v0.3.5

func (f *Filters) Append(key string, value interface{}) *Filters

Append adds a new filter field.

func (*Filters) Float64 added in v0.4.2

func (f *Filters) Float64(field string, value float64) *Filters

float64

func (*Filters) Float64_gt added in v0.3.5

func (f *Filters) Float64_gt(field string, value float64) *Filters

func (*Filters) Float64_gte added in v0.3.5

func (f *Filters) Float64_gte(field string, value float64) *Filters

func (*Filters) Float64_gte_lte added in v0.4.1

func (f *Filters) Float64_gte_lte(field string, value_1, value_2 float64) *Filters

func (*Filters) Float64_in added in v0.3.5

func (f *Filters) Float64_in(field string, values ...float64) *Filters

func (*Filters) Float64_lt added in v0.3.5

func (f *Filters) Float64_lt(field string, value float64) *Filters

func (*Filters) Float64_lte added in v0.3.5

func (f *Filters) Float64_lte(field string, value float64) *Filters

func (*Filters) Float64_nin added in v0.3.5

func (f *Filters) Float64_nin(field string, values ...float64) *Filters

func (*Filters) Int added in v0.4.2

func (f *Filters) Int(field string, value int) *Filters

int

func (*Filters) Int64 added in v0.4.2

func (f *Filters) Int64(field string, value int64) *Filters

int64

func (*Filters) Int64_gt added in v0.3.5

func (f *Filters) Int64_gt(field string, value int64) *Filters

func (*Filters) Int64_gte added in v0.3.5

func (f *Filters) Int64_gte(field string, value int64) *Filters

func (*Filters) Int64_gte_lt added in v0.4.1

func (f *Filters) Int64_gte_lt(field string, value_1, value_2 int64) *Filters

func (*Filters) Int64_gte_lte added in v0.4.1

func (f *Filters) Int64_gte_lte(field string, value_1, value_2 int64) *Filters

func (*Filters) Int64_in added in v0.3.5

func (f *Filters) Int64_in(field string, values ...int64) *Filters

func (*Filters) Int64_lt added in v0.3.5

func (f *Filters) Int64_lt(field string, value int64) *Filters

func (*Filters) Int64_lte added in v0.3.5

func (f *Filters) Int64_lte(field string, value int64) *Filters

func (*Filters) Int64_nin added in v0.3.5

func (f *Filters) Int64_nin(field string, values ...int64) *Filters

func (*Filters) Int_gt added in v0.3.5

func (f *Filters) Int_gt(field string, value int) *Filters

func (*Filters) Int_gte added in v0.3.5

func (f *Filters) Int_gte(field string, value int) *Filters

func (*Filters) Int_gte_lte added in v0.4.1

func (f *Filters) Int_gte_lte(field string, value_1, value_2 int) *Filters

func (*Filters) Int_in added in v0.3.5

func (f *Filters) Int_in(field string, values ...int) *Filters

func (*Filters) Int_lt added in v0.3.5

func (f *Filters) Int_lt(field string, value int) *Filters

func (*Filters) Int_lte added in v0.3.5

func (f *Filters) Int_lte(field string, value int) *Filters

func (*Filters) Int_nin added in v0.3.5

func (f *Filters) Int_nin(field string, values ...int) *Filters

func (*Filters) Log added in v0.4.2

func (f *Filters) Log(msg string)

func (*Filters) NotStates added in v0.4.6

func (f *Filters) NotStates(states ...string) *Filters

func (*Filters) ObjectId added in v0.4.2

func (f *Filters) ObjectId(field string, value primitive.ObjectID) *Filters

ObjectId

func (*Filters) ObjectId_in added in v0.3.5

func (f *Filters) ObjectId_in(field string, values []primitive.ObjectID) *Filters

func (*Filters) States added in v0.4.6

func (f *Filters) States(states ...string) *Filters

func (*Filters) String_in added in v0.3.5

func (f *Filters) String_in(field string, values ...string) *Filters

func (*Filters) String_like added in v0.5.2

func (f *Filters) String_like(field string, value string) *Filters

string

func (*Filters) String_nin added in v0.4.6

func (f *Filters) String_nin(field string, values ...string) *Filters

func (*Filters) Ts added in v0.3.5

func (f *Filters) Ts(ts_from, ts_to int64) *Filters

Set Ts, $gte: ts_from $lt: ts_to

func (*Filters) TsField added in v0.3.5

func (f *Filters) TsField(ts_from, ts_to int64, field string) *Filters

Field like Ts, $gte: ts_from $lt: ts_to

func (*Filters) TsIn added in v0.3.7

func (f *Filters) TsIn(tss ...int64) *Filters

type Index added in v0.3.1

type Index struct {
	Fields interface{}
	Unique bool
}

type Indexes added in v0.3.1

type Indexes []Index

type Manager added in v0.5.8

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

func NewManager added in v0.5.8

func NewManager() Manager

func (*Manager) GetColl added in v0.5.8

func (m *Manager) GetColl(env, conn_name, db_name, coll_name string, indexes ...Index) (CollManager, error)

func (Manager) Log added in v0.5.8

func (m Manager) Log()

type Sorts added in v0.3.5

type Sorts struct {
	Fields bson.D
}

func Sort added in v0.3.6

func Sort() *Sorts

func (*Sorts) Append added in v0.3.5

func (s *Sorts) Append(key string, value int) *Sorts

Append agrega un nuevo campo de ordenación con su dirección.

func (*Sorts) Asc added in v0.3.5

func (s *Sorts) Asc(key string) *Sorts

Ascending agrega un campo para ordenar en dirección ascendente.

func (*Sorts) Desc added in v0.3.5

func (s *Sorts) Desc(key string) *Sorts

Descending agrega un campo para ordenar en dirección descendente.

func (*Sorts) Log added in v0.4.2

func (s *Sorts) Log(msg string)

func (*Sorts) TsAsc added in v0.3.5

func (s *Sorts) TsAsc() *Sorts

func (*Sorts) TsDesc added in v0.3.5

func (s *Sorts) TsDesc() *Sorts

type TsModel

type TsModel struct {
	mgm.DefaultModel `bson:",inline"`
	UnixTs           int64 `bson:"ts" json:"ts"`
}

Jump to

Keyboard shortcuts

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