repository

package
v0.0.0-...-df4b7d7 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 (*ArticleRepositoryInMemory) GetAll

func (*ArticleRepositoryInMemory) GetByID

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 (*ArticleRepositoryMongoDB) Drop

func (repo *ArticleRepositoryMongoDB) Drop() error

Dropping the collection for integration testing.

func (*ArticleRepositoryMongoDB) GetAll

func (repo *ArticleRepositoryMongoDB) GetAll(ctx context.Context) ([]*data.Article, error)

func (*ArticleRepositoryMongoDB) GetByID

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.

Jump to

Keyboard shortcuts

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