Documentation ¶
Index ¶
- type Handler
- type MongoRepository
- func (r *MongoRepository) Create(ctx context.Context, a *types.Article) error
- func (r *MongoRepository) Delete(ctx context.Context, id string) error
- func (r *MongoRepository) FindAll(ctx context.Context, offset, limit int) ([]*types.Article, error)
- func (r *MongoRepository) FindByCreatedByID(ctx context.Context, id string) ([]*types.Article, error)
- func (r *MongoRepository) FindByCreatedTime(ctx context.Context, from time.Time, to time.Time) ([]*types.Article, error)
- func (r *MongoRepository) Get(ctx context.Context, id string) (*types.Article, error)
- func (r *MongoRepository) Increase(ctx context.Context, id string, field string, val interface{}) error
- func (r *MongoRepository) Update(ctx context.Context, id string, a *types.Article) error
- type Repository
- type Service
- func (s *Service) Create(ctx context.Context, a *types.Article) error
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) FindAll(ctx context.Context, offset, limit int) ([]*types.Article, error)
- func (s *Service) Get(ctx context.Context, id string) (*types.Article, error)
- func (s *Service) Update(ctx context.Context, id string, a *types.Article) error
- func (s *Service) View(ctx context.Context, id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is friend web handler
type MongoRepository ¶
type MongoRepository struct {
// contains filtered or unexported fields
}
MongoRepository is MongoDB implementation of repository
func NewMongoRepository ¶
func NewMongoRepository(s *mgo.Session) *MongoRepository
NewMongoRepository return new MongoDB repository
func (*MongoRepository) Delete ¶
func (r *MongoRepository) Delete(ctx context.Context, id string) error
Delete delete the given article from database
func (*MongoRepository) FindByCreatedByID ¶
func (*MongoRepository) FindByCreatedTime ¶
type Repository ¶
type Repository interface { FindAll(ctx context.Context, offset, limit int) ([]*types.Article, error) Increase(ctx context.Context, id string, field string, val interface{}) error }
Repository is an interface of an article repository
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an article service
func NewService ¶
func NewService(r Repository, l glog.Logger) *Service
NewService return a new article service
Click to show internal directories.
Click to hide internal directories.