Documentation
¶
Index ¶
- type JsonRepository
- func (r *JsonRepository) Create(todo *model.Todo) error
- func (r *JsonRepository) Delete(id int) error
- func (r *JsonRepository) Get(id int) (*model.Todo, error)
- func (r *JsonRepository) GetAll(filter string, sorting model.Sorting, pagination model.Pagination) ([]*model.Todo, error)
- func (r *JsonRepository) Shutdown() error
- func (r *JsonRepository) Update(todo *model.Todo) error
- type MongoRepository
- func (r *MongoRepository) Create(todo *model.Todo) error
- func (r *MongoRepository) Delete(id int) error
- func (r *MongoRepository) Get(id int) (*model.Todo, error)
- func (r *MongoRepository) GetAll(filterS string, sorting model.Sorting, pagination model.Pagination) ([]*model.Todo, error)
- func (r *MongoRepository) Shutdown() error
- func (r *MongoRepository) Update(todo *model.Todo) error
- type Repository
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) 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
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) GetAll ¶
func (r *MongoRepository) GetAll(filterS string, sorting model.Sorting, pagination model.Pagination) ([]*model.Todo, error)
func (*MongoRepository) Shutdown ¶
func (r *MongoRepository) Shutdown() 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)
Click to show internal directories.
Click to hide internal directories.