repository

package
v0.0.0-...-d3d3440 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonRepository

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

func (*JsonRepository) Create

func (r *JsonRepository) Create(todo *model.Todo) error

Create a new todo

func (*JsonRepository) Delete

func (r *JsonRepository) Delete(id int) error

Delete a todo

func (*JsonRepository) Get

func (r *JsonRepository) Get(id int) (*model.Todo, error)

Get a todo by id

func (*JsonRepository) GetAll

func (r *JsonRepository) GetAll(filter string, sorting model.Sorting, pagination model.Pagination) ([]*model.Todo, error)

Get all todos

func (*JsonRepository) Shutdown

func (r *JsonRepository) Shutdown() error

func (*JsonRepository) Update

func (r *JsonRepository) Update(todo *model.Todo) error

Update a todo

type MongoRepository

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

func NewMongoRepository

func NewMongoRepository(client *mongo.Client, databaseName, collectionName string) (*MongoRepository, error)

func (*MongoRepository) Create

func (r *MongoRepository) Create(todo *model.Todo) error

Create method using MongoDB

func (*MongoRepository) Delete

func (r *MongoRepository) Delete(id int) error

func (*MongoRepository) Get

func (r *MongoRepository) Get(id int) (*model.Todo, error)

func (*MongoRepository) GetAll

func (r *MongoRepository) GetAll(filterS string, sorting model.Sorting, pagination model.Pagination) ([]*model.Todo, error)

func (*MongoRepository) Shutdown

func (r *MongoRepository) Shutdown() error

func (*MongoRepository) Update

func (r *MongoRepository) Update(todo *model.Todo) error

type Repository

type Repository interface {
	// Create a new todo
	Create(todo *model.Todo) error
	// Get a todo by id
	Get(id int) (*model.Todo, error)
	// Get all todos
	GetAll(filter string, sorting model.Sorting, pagination model.Pagination) ([]*model.Todo, error)
	// Update a todo
	Update(todo *model.Todo) error
	// Delete a todo
	Delete(id int) error

	Shutdown() error
}

func New

func New(client interface{}) (Repository, error)

func NewJSONRepository

func NewJSONRepository(db *os.File) (Repository, error)

Jump to

Keyboard shortcuts

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