mongodb

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexData

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

IndexData keeps index creation data

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

type TextRecord

type TextRecord struct {
	ID      string    `json:"id"`
	Type    int       `json:"type"`
	Text    string    `json:"text"`
	Created time.Time `json:"created,omitempty"`
	Tags    []string  `json:"tags,omitempty"`
}

TextRecord data in mongo db

type TextSaver

type TextSaver struct {
	SessionProvider *SessionProvider
}

TextSaver saves text to mongo DB

func NewTextSaver

func NewTextSaver(sessionProvider *SessionProvider) (*TextSaver, error)

NewTextSaver creates TextSaver instance

func (*TextSaver) All

func (ss *TextSaver) All() ([]*TextRecord, error)

All loads all records

func (*TextSaver) Delete added in v0.2.387

func (ss *TextSaver) Delete(ID string) (int, error)

Delete deletes records from db

func (*TextSaver) GetCount added in v0.2.387

func (ss *TextSaver) GetCount(requestID string, reqType utils.RequestTypeEnum) (int64, error)

GetCount by ID and type

func (*TextSaver) LoadText

func (ss *TextSaver) LoadText(requestID string, reqType utils.RequestTypeEnum) (string, error)

LoadText by ID and type

func (*TextSaver) Save

func (ss *TextSaver) Save(req, text string, reqType utils.RequestTypeEnum, tags []string) error

Save text to DB

Jump to

Keyboard shortcuts

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