repositories

package
v11.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

README

Repositories

The package which has direct access to the "datasource" and can manipulate data directly.

Documentation

Index

Constants

View Source
const (
	// ReadOnlyMode will RLock(read) the data .
	ReadOnlyMode = iota
	// ReadWriteMode will Lock(read/write) the data.
	ReadWriteMode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MovieRepository

type MovieRepository interface {
	Exec(query Query, action Query, limit int, mode int) (ok bool)

	Select(query Query) (movie datamodels.Movie, found bool)
	SelectMany(query Query, limit int) (results []datamodels.Movie)

	InsertOrUpdate(movie datamodels.Movie) (updatedMovie datamodels.Movie, err error)
	Delete(query Query, limit int) (deleted bool)
}

MovieRepository handles the basic operations of a movie entity/model. It's an interface in order to be testable, i.e a memory movie repository or a connected to an sql database.

func NewMovieRepository

func NewMovieRepository(source map[int64]datamodels.Movie) MovieRepository

NewMovieRepository returns a new movie memory-based repository, the one and only repository type in our example.

type Query

type Query func(datamodels.Movie) bool

Query represents the visitor and action queries.

Jump to

Keyboard shortcuts

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