dao

package
v0.0.0-...-0ca455c Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package dao provides access to the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDatabaseInterface

type MongoDatabaseInterface interface {
	Collection(name string, opts ...*options.CollectionOptions) *mongo.Collection
}

MongoDatabaseInterface is an interface that describes the mongodb driver

type MongoService

type MongoService struct {
	CollectionName string
	// contains filtered or unexported fields
}

MongoService is an implementation of the Service interface using MongoDB as the backend driver.

func (*MongoService) CreatePayableResource

func (m *MongoService) CreatePayableResource(dao *models.PayableResourceDao) error

CreatePayableResource will store the payable request into the database

func (*MongoService) GetPayableResource

func (m *MongoService) GetPayableResource(companyNumber, reference string) (*models.PayableResourceDao, error)

GetPayableResource gets the payable request from the database

func (*MongoService) SaveE5Error

func (m *MongoService) SaveE5Error(companyNumber, reference string, action e5.Action) error

SaveE5Error will update the resource by flagging an error in e5 for a particular action

func (*MongoService) Shutdown

func (m *MongoService) Shutdown()

Shutdown is a hook that can be used to clean up db resources

func (*MongoService) UpdatePaymentDetails

func (m *MongoService) UpdatePaymentDetails(dao *models.PayableResourceDao) error

UpdatePaymentDetails will save the document back to Mongo

type Service

type Service interface {
	// CreatePayableResource will persist a newly created resource
	CreatePayableResource(dao *models.PayableResourceDao) error
	// GetPayableResource will find a single payable resource with the given companyNumber and reference
	GetPayableResource(companyNumber, reference string) (*models.PayableResourceDao, error)
	// UpdatePaymentDetails will update the resource with changed values
	UpdatePaymentDetails(dao *models.PayableResourceDao) error
	// SaveE5Error stored which command to E5 failed e.g. create, authorise or confirm
	SaveE5Error(companyNumber, reference string, action e5.Action) error
	// Shutdown can be called to clean up any open resources that the service may be holding on to.
	Shutdown()
}

Service interface declares how to interact with the persistence layer regardless of underlying technology

func NewDAOService

func NewDAOService(cfg *config.Config) Service

NewDAOService will create a new instance of the Service interface. All details about its implementation and the database driver will be hidden from outside of this package

Jump to

Keyboard shortcuts

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