mongodb

package
v0.0.0-...-4e290a4 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAO

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

DAO for handling access to a mongoDB collection

func NewDAO

func NewDAO(dbName, collectioName string, session *Session) *DAO

NewDAO returns a DBcollection used for handling access to a mongoDB collection

func (*DAO) Count

func (d *DAO) Count(ctx context.Context) (int64, error)

func (*DAO) GetAll

func (d *DAO) GetAll(ctx context.Context, items interface{}, limit int64) error

GetAll - return all items from the collection

func (*DAO) GetByID

func (d *DAO) GetByID(ctx context.Context, id string, item interface{}) error

GetByID - return an item from the collection using the ID

func (*DAO) GetList

func (d *DAO) GetList(ctx context.Context, items interface{}, query map[string]interface{}, limit int64) error

GetList - return a list of items from the collection using a query

func (*DAO) GetName

func (d *DAO) GetName() string

GetName - return name of collection

func (*DAO) Insert

func (d *DAO) Insert(ctx context.Context, item interface{}) (string, error)

Insert adds an item to the collection

func (*DAO) RemoveByID

func (d *DAO) RemoveByID(ctx context.Context, id string) error

RemoveByID - removes an item from the collection

func (*DAO) UpdateByID

func (d *DAO) UpdateByID(ctx context.Context, id string, item interface{}) error

UpdateByID - updates an item in the collection using a key value pair

type Session

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

Session wraps a mgo.Database to embed methods in models.

func NewSession

func NewSession(ctx context.Context, server, dbUser, dbPassword string) (*Session, error)

NewSession creates a session for mongoDB

func (Session) Close

func (s Session) Close(ctx context.Context)

Close - closes database session

func (Session) GetClient

func (s Session) GetClient() *mongo.Client

GetClient returns database client

Jump to

Keyboard shortcuts

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