storage

package
v0.0.0-...-764ed56 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMongoDB

func InitMongoDB(ctx context.Context, conf config.Getter) error

Types

type CachedCollection

type CachedCollection struct {
	CollectionURL     string `json:"collection_url,omitempty" mapstructure:"collection_url"`
	CacheURL          string `json:"cache_url,omitempty" mapstructure:"cache_url"`
	CacheExpiration   int    `json:"cache_expiration,omitempty" mapstructure:"cache_expiration"`
	EnableTransaction bool   `json:"enable_transaction,omitempty" mapstructure:"enable_transaction"`
	Driver            string
	Collection        *docstore.Collection
	Cache             simplecache.Cache
}

func New

func (*CachedCollection) BulkCreate

func (c *CachedCollection) BulkCreate(ctx context.Context, docs []Document) error

func (*CachedCollection) BulkGet

func (c *CachedCollection) BulkGet(ctx context.Context, out []interface{}) error

func (*CachedCollection) Create

func (c *CachedCollection) Create(ctx context.Context, doc Document) error

func (*CachedCollection) Delete

func (c *CachedCollection) Delete(ctx context.Context, doc Document) error

func (*CachedCollection) Find

func (c *CachedCollection) Find(ctx context.Context, opt *QueryOpt, out interface{}) error

func (*CachedCollection) Get

func (c *CachedCollection) Get(ctx context.Context, out Document) error

func (*CachedCollection) GetMongoSession

func (c *CachedCollection) GetMongoSession() (mongo.Session, error)

GetMongoSession get mongo session

func (*CachedCollection) Increment

func (c *CachedCollection) Increment(ctx context.Context, doc Document, fieldName string, value int) error

func (*CachedCollection) Replace

func (c *CachedCollection) Replace(ctx context.Context, doc Document) error

func (*CachedCollection) Update

func (c *CachedCollection) Update(ctx context.Context, doc Document) error

func (*CachedCollection) UpdateField

func (c *CachedCollection) UpdateField(ctx context.Context, doc Document, fieldName string, value interface{}) error

type Document

type Document interface {
	GetID() string
	GenerateID() Document
	SetCreatedTime(t time.Time) Document
	GetCreatedTime() time.Time
}

type FilterOpt

type FilterOpt struct {
	Field string
	Value interface{}
	Ops   string
}

FilterOpt filter option

func (*FilterOpt) ToMongoM

func (f *FilterOpt) ToMongoM() bson.M

type QueryOpt

type QueryOpt struct {
	Limit    int
	Skip     int
	Page     int
	OrderBy  string
	IsAscend bool
	Filter   []FilterOpt
}

QueryOpt query option

func (*QueryOpt) AddFilter

func (q *QueryOpt) AddFilter(filter FilterOpt) *QueryOpt

func (*QueryOpt) Normalize

func (q *QueryOpt) Normalize() *QueryOpt

func (*QueryOpt) ToDocstoreQuery

func (q *QueryOpt) ToDocstoreQuery(query *docstore.Query)

func (*QueryOpt) ToMongoFilter

func (q *QueryOpt) ToMongoFilter() (bson.M, *options.FindOptions)

Jump to

Keyboard shortcuts

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