rMongo

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 12 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 CreateMany added in v0.1.6

func CreateMany[T []mgm.Model](models T, coll Collection) error

CreateMany

func GetFields added in v0.1.7

func GetFields(sort rSort.Sorts) bson.D

func GetID

func GetID(id interface{}) primitive.ObjectID

func GetIDs

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

func NewFilter

func NewFilter() rFilter.Filters

func NewSort added in v0.1.3

func NewSort() rSort.Sorts

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

Create

func (*Collection) Drop

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

func (*Collection) Filters

func (c *Collection) Filters(f rFilter.Filters) *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) Mgm added in v0.1.6

func (c Collection) Mgm() *mgm.Collection

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 rSort.Sorts) *Collection

func (Collection) Update

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

Update

func (Collection) Upsert

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

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 {
	// contains filtered or unexported fields
}

func (*Filter) Append

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

func (Filter) Clone

func (f Filter) Clone() rFilter.Inter

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) Id added in v0.1.7

func (f *Filter) Id(id 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{})

func (Filter) String added in v0.1.3

func (f Filter) String() string

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 (*Sort) Append

func (s *Sort) Append(field string, value interface{})

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

func (*Sort) Asc

func (s *Sort) Asc(field string)

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

func (Sort) Clone added in v0.1.3

func (s Sort) Clone() rSort.Inter

func (*Sort) Desc

func (s *Sort) Desc(field string)

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

func (Sort) Log

func (s Sort) Log(msg string)

func (Sort) String added in v0.1.3

func (s Sort) String() string

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