repository

package
v0.0.0-...-3215105 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListParameters

type ListParameters struct {
	IDs    []int  `form:"ids"`
	Limit  int    `form:"limit"`
	Offset int    `form:"offset"`
	Order  string `form:"order"`
}

List Parameters contains fields common for queries

func (ListParameters) ContainsParameters

func (l ListParameters) ContainsParameters() bool

ContainsParameters checks whether given 'ListParameters' Has any parameters of non-zero value

type Repository

type Repository interface {
	// Create a new entry for specified 'req' object.
	Create(req interface{}) (err *dberrors.Error)

	// For specific 'req' object the Get method returns first result that match a query
	// where all fields matched with a 'req' would be present.
	// I.e. for:
	// type Foo struct {
	// 	ID int
	//	Name string
	//  Age int
	// }
	// if 'req' would contain ID=1 the record with id=1 would be returned
	// if 'req' fields Age=20 and Name='some name' the first record that match
	// Age=20 and Name='some name' would be returned
	Get(req interface{}) (res interface{}, err *dberrors.Error)

	// List search and list all objects of given type
	// 'req' specify what field values should be present in the result.
	// i.e. if 'req' is a of type Foo struct {Name string} then, providing
	// 'req' &Foo{Name: "Some name"} would list all entries containing field "Name='Some name'"
	List(req interface{}) (res interface{}, err *dberrors.Error)

	// List search and list all objects of given type
	// It extends the List method by providing query parameters.
	// Using list parameters allows i.e. paginate the results or specify order of the query
	// By providing 'IDs' field all entries with given ID's would be queried
	ListWithParams(req interface{}, params *ListParameters) (res interface{}, err *dberrors.Error)

	// Count returns the number of record defined by 'req' argument
	Count(req interface{}) (count int, dbErr *dberrors.Error)

	// Update replaces the whole object with given in argument
	// If no primary key provided in the 'req' or given 'primary key' is not found
	// in the collection than new record is being created
	Update(req interface{}) (err *dberrors.Error)

	// Patch updates only selected fields in the 'req' object
	// selected from 'where' object
	// if where is nil object then all records for given table would be patched.
	Patch(req, where interface{}) (err *dberrors.Error)

	// Delete given records from database defined by 'req' object
	// 'where' describes which entries should be deleted.
	// if where is nil all entries for given model should be deleted.
	Delete(req, where interface{}) (err *dberrors.Error)
}

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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