mongo

package
v0.0.0-...-fc3a142 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrudService

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

MongoCollectionStore stores Book instances in a MongoDB collection.

func NewCrudService

func NewCrudService(mongoURI, database, collection string) (*CrudService, error)

NewStorage creates a new Storage backed by MongoDB

func (*CrudService) Add

func (cs *CrudService) Add(ctx context.Context, book model.Book) (model.Book, error)

Add adds a new book

func (*CrudService) Close

func (m *CrudService) Close(ctx context.Context) error

func (*CrudService) Get

func (cs *CrudService) Get(ctx context.Context, id string) (model.Book, error)

Book finds a book by its ID.

func (*CrudService) List

func (cs *CrudService) List(ctx context.Context, limit int) ([]model.Book, error)

All returns all books up to 'limit' instances.

func (*CrudService) Ping

func (m *CrudService) Ping(ctx context.Context) error

func (*CrudService) Remove

func (cs *CrudService) Remove(ctx context.Context, id string) (model.Book, error)

Remove deletes a book from the database

func (*CrudService) Update

func (cs *CrudService) Update(ctx context.Context, id string, book model.Book) (model.Book, error)

Update a book for specific ID

Jump to

Keyboard shortcuts

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