repository

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 3 Imported by: 0

README

  • Repository is a place where you communicate with the real external data source, like database, cloud service, external service, etc.
  • You should keep your repository as simple as possible, don't add too much logic here
  • If you have to, you can separate the operations into smaller methods, then do the flow in the service package
  • You should always call your repository methods inside the service package
  • You may use your src/library functions directly in this package
  • Any changes outside this package should not affect your repositories (except changes for business entity)
  • If you need config variables, database frameworks, or external clients, pass/inject them as dependency
  • You can use your own style as long as it doesn't break the main idea

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Example added in v2.1.0

type Example interface {
	// FindAll finds all example data.
	FindAll(param ExampleFindAllParam) ExampleFindAllResult
}

func NewExampleMySQL added in v2.1.0

func NewExampleMySQL(param NewExampleMySQLParam) Example

NewExampleMySQL generates new exampleMySQL that implements Example.

type ExampleFindAllParam added in v2.1.0

type ExampleFindAllParam struct {
	Ctx context.Context // In case you need a context.
}

type ExampleFindAllResult added in v2.1.0

type ExampleFindAllResult struct {
	Examples []*entity.Example `json:"examples"`
	Error    error             `json:"error"`
}

type NewExampleMySQLParam added in v2.1.0

type NewExampleMySQLParam struct {
	DB *sql.DB
}

type NewParam

type NewParam struct {
	MySQLDB *sql.DB
}

type Repository

type Repository struct {
	Example Example
}

func New

func New(param NewParam) *Repository

New generates new repository.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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