repositories

package
v8.5.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: BSD-3-Clause Imports: 3 Imported by: 0

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 Query

type Query func(datamodels.User) bool

Query represents the visitor and action queries.

type UserRepository

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

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

	InsertOrUpdate(user datamodels.User) (updatedUser datamodels.User, err error)
	Delete(query Query, limit int) (deleted bool)
}

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

func NewUserRepository

func NewUserRepository(source map[int64]datamodels.User) UserRepository

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

Jump to

Keyboard shortcuts

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