repository

package
v0.0.0-...-a093bcc Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("fact not found")
)

Functions

This section is empty.

Types

type Fact

type Fact struct {
	ID        primitive.ObjectID `bson:"_id" json:"id"`
	Fact      string             `bson:"fact" json:"fact"`
	Source    string             `bson:"source" json:"source"`
	Approved  bool               `bson:"approved" json:"approved"`
	CreatedAt time.Time          `bson:"created_at" json:"createdAt"`
	CreatedBy string             `bson:"created_by" json:"createdBy"`
	UpdatedAt time.Time          `bson:"updated_at" json:"updatedAt"`
	UpdatedBy string             `bson:"updated_by" json:"updatedBy"`
}

type FactsRepository

type FactsRepository interface {
	Create(fact *Fact) error
	ReadOne(id primitive.ObjectID) (*Fact, error)
	ReadManyIDs(filterFunc func(fact *Fact) bool) ([]primitive.ObjectID, error)
	ReadAll() ([]*Fact, error)
	Update(id primitive.ObjectID, updateFunc func(fact *Fact) *Fact) error
	Delete(id primitive.ObjectID) error
	Count() (int, error)
	Close() error
}

func NewMockFactsRepository

func NewMockFactsRepository(facts map[primitive.ObjectID]*Fact, errorAllFunctionCalls bool) FactsRepository

func NewMongoDBFactsRepository

func NewMongoDBFactsRepository(mongoDbUri string) (FactsRepository, error)

type MockFactsRepository

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

func (*MockFactsRepository) Close

func (m *MockFactsRepository) Close() error

func (*MockFactsRepository) Count

func (m *MockFactsRepository) Count() (int, error)

func (*MockFactsRepository) Create

func (m *MockFactsRepository) Create(fact *Fact) error

func (*MockFactsRepository) Delete

func (*MockFactsRepository) ReadAll

func (m *MockFactsRepository) ReadAll() ([]*Fact, error)

func (*MockFactsRepository) ReadManyIDs

func (m *MockFactsRepository) ReadManyIDs(filterFunc func(fact *Fact) bool) ([]primitive.ObjectID, error)

func (*MockFactsRepository) ReadOne

func (m *MockFactsRepository) ReadOne(id primitive.ObjectID) (*Fact, error)

func (*MockFactsRepository) Update

func (m *MockFactsRepository) Update(id primitive.ObjectID, updateFunc func(fact *Fact) *Fact) error

type MongoDBFactsRepository

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

func (*MongoDBFactsRepository) Close

func (m *MongoDBFactsRepository) Close() error

func (*MongoDBFactsRepository) Count

func (m *MongoDBFactsRepository) Count() (int, error)

func (*MongoDBFactsRepository) Create

func (m *MongoDBFactsRepository) Create(fact *Fact) error

func (*MongoDBFactsRepository) Delete

func (*MongoDBFactsRepository) ReadAll

func (m *MongoDBFactsRepository) ReadAll() ([]*Fact, error)

func (*MongoDBFactsRepository) ReadManyIDs

func (m *MongoDBFactsRepository) ReadManyIDs(filterFunc func(fact *Fact) bool) ([]primitive.ObjectID, error)

func (*MongoDBFactsRepository) ReadOne

func (m *MongoDBFactsRepository) ReadOne(id primitive.ObjectID) (*Fact, error)

func (*MongoDBFactsRepository) Update

func (m *MongoDBFactsRepository) Update(id primitive.ObjectID, updateFunc func(fact *Fact) *Fact) error

Jump to

Keyboard shortcuts

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