Documentation
¶
Index ¶
- type ArticleRepositoryInMemory
- func (r *ArticleRepositoryInMemory) Create(ctx context.Context, article *data.ArticleInfo) (data.ArticleID, error)
- func (r *ArticleRepositoryInMemory) GetAll(ctx context.Context) ([]*data.Article, error)
- func (r *ArticleRepositoryInMemory) GetByID(ctx context.Context, id data.ArticleID) (*data.Article, error)
- type ArticleRepositoryMongoDB
- func (repo *ArticleRepositoryMongoDB) Close() error
- func (repo *ArticleRepositoryMongoDB) Create(ctx context.Context, article *data.ArticleInfo) (data.ArticleID, error)
- func (repo *ArticleRepositoryMongoDB) Drop() error
- func (repo *ArticleRepositoryMongoDB) GetAll(ctx context.Context) ([]*data.Article, error)
- func (repo *ArticleRepositoryMongoDB) GetByID(ctx context.Context, id data.ArticleID) (*data.Article, error)
- type DBArticle
- type DBArticleInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArticleRepositoryInMemory ¶
type ArticleRepositoryInMemory struct {
// contains filtered or unexported fields
}
In-memory implementation of ArticleRepository.
func NewArticleRepositoryInMemory ¶
func NewArticleRepositoryInMemory() *ArticleRepositoryInMemory
func (*ArticleRepositoryInMemory) Create ¶
func (r *ArticleRepositoryInMemory) Create(ctx context.Context, article *data.ArticleInfo) (data.ArticleID, error)
type ArticleRepositoryMongoDB ¶
type ArticleRepositoryMongoDB struct {
// contains filtered or unexported fields
}
ArticleRepositoryMongoDB is a MongoDB implementation of ArticleRepository.
func NewArticleRepositoryMongoDB ¶
func NewArticleRepositoryMongoDB(mongoUri string) (*ArticleRepositoryMongoDB, error)
NewArticleRepositoryMongoDB creates a new ArticleRepositoryMongoDB connecting to a MongoDB.
func (*ArticleRepositoryMongoDB) Close ¶
func (repo *ArticleRepositoryMongoDB) Close() error
func (*ArticleRepositoryMongoDB) Create ¶
func (repo *ArticleRepositoryMongoDB) Create(ctx context.Context, article *data.ArticleInfo) (data.ArticleID, error)
func (*ArticleRepositoryMongoDB) Drop ¶
func (repo *ArticleRepositoryMongoDB) Drop() error
Dropping the collection for integration testing.
type DBArticle ¶
type DBArticle struct { ID primitive.ObjectID `bson:"_id"` Title string `bson:"title"` Content string `bson:"content"` Author string `bson:"author"` }
Data for reading from MongoDB, with extra field "_id".
type DBArticleInfo ¶
type DBArticleInfo struct { Title string `bson:"title"` Content string `bson:"content"` Author string `bson:"author"` }
Data for inserting into MongoDB.
Click to show internal directories.
Click to hide internal directories.