sMongo

package
v2.0.0 Latest Latest
Warning

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

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

README

sMongo

Default dir:

.env/mongodb/

Make a file with this format on default dir:

Write.yaml

environment: write username: devWrite password: devWritePass host: mongo_db port: 27017 auth_database: admin

Documentation

Index

Constants

View Source
const (
	// Environment
	EnvironmentWrite = Environment("write")
	EnvironmentRead  = Environment("read")
)

Variables

This section is empty.

Functions

func GetID

func GetID(id interface{}) primitive.ObjectID

func GetIDs

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

Types

type Client

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

type ClientsMap

type ClientsMap map[string]*Client

type Collection

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

func (Collection) Agregates

func (c Collection) Agregates(docs interface{}) error

func (Collection) AgregatesCount

func (c Collection) AgregatesCount() ([]bson.M, error)

func (Collection) AgregatesCountWithCtx

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

func (Collection) AgregatesWithCtx

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

func (Collection) Count

func (c Collection) Count() (int64, error)

Count

func (Collection) Create

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

Create

func (*Collection) Drop

func (c *Collection) Drop(indexes ...Index) error

func (*Collection) Filters

func (c *Collection) Filters(f Filter) *Collection

func (Collection) Find

func (c Collection) Find(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(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) GetTss

func (c Collection) GetTss() ([]int64, error)

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

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

func (Collection) Log

func (c Collection) Log()

func (*Collection) Pipeline

func (c *Collection) Pipeline(p Pipeline) *Collection

func (Collection) Prefix

func (c Collection) Prefix() string

func (*Collection) Sorts

func (c *Collection) Sorts(s Sort) *Collection

func (Collection) Update

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

Update

func (Collection) Upsert

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

Upsert

type CollectionsMap

type CollectionsMap map[string]*Collection

type Connection

type Connection 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"`
}

Connection, Databases access data

type Database

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

type DatabasesMap

type DatabasesMap map[string]*Database

type Environment

type Environment string

type Filter

type Filter struct {
	*sFilter.Filters // Embedding filters by adding behaviors to the filter
	// contains filtered or unexported fields
}

func Filters

func Filters() *Filter

func (*Filter) Append

func (f *Filter) Append(field string, value interface{})

func (Filter) Fields

func (f Filter) Fields() bson.D

func (*Filter) Gt

func (f *Filter) Gt(field string, value interface{})

func (*Filter) GtLt

func (f *Filter) GtLt(field string, value_1, value_2 interface{})

func (*Filter) GtLte

func (f *Filter) GtLte(field string, value_1, value_2 interface{})

func (*Filter) Gte

func (f *Filter) Gte(field string, value interface{})

func (*Filter) GteLt

func (f *Filter) GteLt(field string, value_1, value_2 interface{})

func (*Filter) GteLte

func (f *Filter) GteLte(field string, value_1, value_2 interface{})

func (*Filter) In

func (f *Filter) In(field string, values ...interface{})

func (*Filter) Like

func (f *Filter) Like(field string, value string)

func (Filter) Log

func (f Filter) Log(msg string)

func (*Filter) Lt

func (f *Filter) Lt(field string, value interface{})

func (*Filter) Lte

func (f *Filter) Lte(field string, value interface{})

func (*Filter) Nin

func (f *Filter) Nin(field string, values ...interface{})

type Index

type Index struct {
	Fields interface{}
	Unique bool
}

type Indexes

type Indexes []Index

type Manager

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

func NewManager

func NewManager() Manager

func (*Manager) GetColl

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

func (Manager) Log

func (m Manager) Log()

type Pipeline

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

func Pipelines

func Pipelines() *Pipeline

func (*Pipeline) Append

func (p *Pipeline) Append(field string, value interface{})

func (Pipeline) Fields

func (p Pipeline) Fields() bson.D

func (Pipeline) Log

func (f Pipeline) Log(msg string)

type Sort

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

func Sorts

func Sorts() *Sort

func (*Sort) Append

func (s *Sort) Append(field string, value int) *Sort

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

func (*Sort) Asc

func (s *Sort) Asc(field string) *Sort

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

func (*Sort) Desc

func (s *Sort) Desc(field string) *Sort

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

func (Sort) Fields

func (s Sort) Fields() bson.D

func (Sort) Log

func (s Sort) Log(msg string)

func (*Sort) TsAsc

func (s *Sort) TsAsc() *Sort

func (*Sort) TsDesc

func (s *Sort) TsDesc() *Sort

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