datasource

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexDaysAgo        = regexp.MustCompile(`^\$(\d+)dago$`)
	RegexWeeksAgo       = regexp.MustCompile(`^\$(\d+)wago$`)
	RegexMonthsAgo      = regexp.MustCompile(`^\$(\d+)mago$`)
	RegexYearsAgo       = regexp.MustCompile(`^\$(\d+)yago$`)
	RegexSecondsAgo     = regexp.MustCompile(`^\$(\d+)Sago$`)
	RegexMinutesAgo     = regexp.MustCompile(`^\$(\d+)Mago$`)
	RegexHoursAgo       = regexp.MustCompile(`^\$(\d+)Hago$`)
	RegexDaysFromNow    = regexp.MustCompile(`^\$(\d+)dfromnow$`)
	RegexWeeksFromNow   = regexp.MustCompile(`^\$(\d+)wfromnow$`)
	RegexMonthsFromNow  = regexp.MustCompile(`^\$(\d+)mfromnow$`)
	RegexYearsFromNow   = regexp.MustCompile(`^\$(\d+)yfromnow$`)
	RegexSecondsFromNow = regexp.MustCompile(`^\$(\d+)Sfromnow$`)
	RegexMinutesFromNow = regexp.MustCompile(`^\$(\d+)Mfromnow$`)
	RegexHoursFromNow   = regexp.MustCompile(`^\$(\d+)Hfromnow$`)
)

Functions

func ReplaceObjectIds added in v1.2.12

func ReplaceObjectIds(data interface{}) interface{}

Types

type CursorIterator added in v1.6.0

type CursorIterator chan interface{}

type Datasource

type Datasource struct {
	Name    string
	Db      interface{}
	Viper   *viper.Viper
	Key     string
	Context context.Context
	Options *Options

	SubViper *viper.Viper
	// contains filtered or unexported fields
}

func New

func New(dsKey string, dsViper *viper.Viper, parentContext context.Context) *Datasource

func (*Datasource) Count added in v1.5.40

func (ds *Datasource) Count(collectionName string, lookups *wst.A) (int64, error)

func (*Datasource) Create

func (ds *Datasource) Create(collectionName string, data *wst.M) (*wst.M, error)

func (*Datasource) DeleteById

func (ds *Datasource) DeleteById(collectionName string, id interface{}) int64

func (*Datasource) FindMany

func (ds *Datasource) FindMany(collectionName string, lookups *wst.A) (MongoCursorI, error)

FindMany retrieves data from the specified collection based on the provided lookup conditions using the appropriate data source connector specified in the configuration file. @param collectionName string: the name of the collection from which to retrieve data. @param lookups *wst.A: a pointer to an array of conditions to be used as lookup criteria. If nil, all data in the collection will be returned. @return MongoCursorI: a cursor to the result set that matches the lookup criteria, or an error if an error occurs while attempting to retrieve the data. The cursor needs to be closed outside of the function. Implementations for Redis and memorykv connectors are not yet implemented and will result in an error.

func (*Datasource) Initialize

func (ds *Datasource) Initialize() error

func (*Datasource) UpdateById

func (ds *Datasource) UpdateById(collectionName string, id interface{}, data *wst.M) (*wst.M, error)

type MongoCursorI added in v1.6.0

type MongoCursorI interface {
	Next(ctx context.Context) bool
	Decode(val interface{}) error
	All(ctx context.Context, val interface{}) error
	Close(ctx context.Context) error
}

func NewFixedMongoCursor added in v1.6.0

func NewFixedMongoCursor(rawInputs [][]byte) MongoCursorI

type MongoDBDatasourceOptions added in v1.5.46

type MongoDBDatasourceOptions struct {
	Registry     *bsoncodec.Registry
	Monitor      *event.CommandMonitor
	Timeout      int
	RetryOnError bool
}

type OperationError

type OperationError struct {
	Code    int
	Message string
}

func NewError

func NewError(code int, message string) *OperationError

func (*OperationError) Error

func (e *OperationError) Error() string

type Options added in v1.3.3

type Options struct {
	MongoDB *MongoDBDatasourceOptions
}

Jump to

Keyboard shortcuts

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