mongo

package
v1.3.71 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: BSD-3-Clause Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCollection

func NewCollection(pr *SessionProvider, tName string) (*mongo.Collection, context.Context, func(), error)

NewCollection initiates new collection for mongo

func Sanitize

func Sanitize(s string) string

Sanitize mongo input

func SkipNoDocErr

func SkipNoDocErr(err error) error

SkipNoDocErr checks error and skips if error is mongo.ErrNoDocuments

Types

type CleanIDsProvider

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

CleanIDsProvider returns old IDs to remove from system

func NewCleanIDsProvider

func NewCleanIDsProvider(sessionProvider *SessionProvider, expireDuration time.Duration, table string) (*CleanIDsProvider, error)

NewCleanIDsProvider creates CleanIDsProvider instances

func (*CleanIDsProvider) GetExpired

func (p *CleanIDsProvider) GetExpired() ([]string, error)

GetExpired return expired IDs

type CleanRecord

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

CleanRecord deletes mongo table record

func NewCleanRecord

func NewCleanRecord(sessionProvider *SessionProvider, table string) (*CleanRecord, error)

NewCleanRecord initiates object

func (*CleanRecord) Clean

func (fs *CleanRecord) Clean(ID string) error

Clean deletes record from table by ID

type IndexData

type IndexData struct {
	Table  string
	Fields []string
	Unique bool
}

IndexData keeps index creation data

func NewIndexData

func NewIndexData(table string, field string, unique bool) IndexData

NewIndexData creates index data

type Locker

type Locker struct {
	SessionProvider *SessionProvider
	// contains filtered or unexported fields
}

Locker acquires lock in db

func NewLocker

func NewLocker(sessionProvider *SessionProvider, table string) (*Locker, error)

NewLocker creates Locker instance

func (*Locker) Lock

func (ss *Locker) Lock(id string, lockKey string) error

Lock locks record for sending email

func (*Locker) UnLock

func (ss *Locker) UnLock(id string, lockKey string, value *int) error

UnLock marks record with specific value

type SessionProvider

type SessionProvider struct {
	URL string
	// contains filtered or unexported fields
}

SessionProvider connects and provides session for mongo DB

func NewSessionProvider

func NewSessionProvider(url string, indexes []IndexData, store string) (*SessionProvider, error)

NewSessionProvider creates Mongo session provider

func (*SessionProvider) Close

func (sp *SessionProvider) Close()

Close closes mongo session

func (*SessionProvider) Healthy

func (sp *SessionProvider) Healthy() error

Healthy checks if mongo DB is up

func (*SessionProvider) NewSession

func (sp *SessionProvider) NewSession() (mongo.Session, error)

NewSession creates mongo session

Jump to

Keyboard shortcuts

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