mongodb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 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) 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