dbutils

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DateMongoFormat = map[string]string{
	"hour":  "%Y-%m-%d %H",
	"day":   "%Y-%m-%d",
	"month": "%Y-%m",
	"week":  "%V",
	"year":  "%Y",
}
View Source
var DateTimeFormat = map[string]string{
	"hour":  "2006-01-02 15",
	"day":   "2006-01-02",
	"month": "2006-01",
	"week":  "",
	"year":  "2006",
}

Functions

This section is empty.

Types

type SimpleQueryBuilder

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

SimpleQueryBuilder is a simple MongoDB query builder.

func (*SimpleQueryBuilder) Build

func (q *SimpleQueryBuilder) Build() bson.M

Build returns the result of the query builder as a bson.M. If Build() is called on a nil value it returns an empty bson.M that would match all documents.

func (*SimpleQueryBuilder) Where

func (q *SimpleQueryBuilder) Where(key string, operator string, value interface{}) *SimpleQueryBuilder

Where matches MongoDB documents where key matches value using operator. If Where overwrites any other "where clause" that used the same key and operator.

func (*SimpleQueryBuilder) WhereIn

func (q *SimpleQueryBuilder) WhereIn(key string, value interface{}) *SimpleQueryBuilder

WhereIn searches from MongoDB documents where the value of key is in a list of values. WhereIn addes value to this list of queried values.

type Stats

type Stats struct {
	ValidGroupBys map[string]bson.M
	ValidTimeKeys map[string]struct{}
	ValidCounts   map[string]bson.M
	Collection    *mongo.Collection
}

func (*Stats) SimpleCount

func (s *Stats) SimpleCount(ctx context.Context, counterKey string) (int, error)

func (*Stats) SimpleGroupBy

func (s *Stats) SimpleGroupBy(ctx context.Context, groupByKey string, counterKey string) ([]stats.Group, error)

func (*Stats) SimpleGroupByOverTime

func (s *Stats) SimpleGroupByOverTime(ctx context.Context, from, to time.Time, timeRange string, groupByKey, timeKey, counterKey string) ([]stats.TimeSeries, error)

Jump to

Keyboard shortcuts

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