mongodb

package
v0.0.0-...-8297c98 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBooksCollectionName = "books"
View Source
const MinObjectId = "000000000000000000000000"

Variables

This section is empty.

Functions

func BookToBson

func BookToBson(b book) bson.M

func ConnectDB

func ConnectDB(dbURI string, dbName string, timeout time.Duration) (db.Factory, error)

ConnectDB connects program to the MongoDB with specified options.

func MustConnectDB

func MustConnectDB(dbURI string, dbName string, timeout time.Duration) db.Factory

MustConnectDB calls ConnectDB but panic when has an error.

Types

type BooksRepo

type BooksRepo struct {
	CollectionName string
}

func (*BooksRepo) GetById

func (r *BooksRepo) GetById(id string) (dto.Book, error)

func (*BooksRepo) GetPaginationSortByTimeDesc

func (r *BooksRepo) GetPaginationSortByTimeDesc(limit int, lastId string) ([]dto.Book, string, error)

func (*BooksRepo) Save

func (r *BooksRepo) Save(b dto.Book) (string, error)

type Factory

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

func (*Factory) GetBooksRepo

func (f *Factory) GetBooksRepo() repo.BooksRepo

Jump to

Keyboard shortcuts

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