model

package
v0.0.0-...-086ef7a Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPgNoRows

func CheckPgNoRows(title string, err error) errstack.E

CheckPgNoRows wraps pg error into errstack.E

func CheckRowsAffected

func CheckRowsAffected(title string, expected int, res orm.Result, err error) errstack.E

CheckRowsAffected asserts that expected number of rows has been affected in the SQL operation.

func DecodeAndSave

func DecodeAndSave(src io.ReadCloser, dest Validated, db *pg.DB) errstack.E

DecodeAndSave is handy model function which decodes, validates and save an object into DB. `dest` must be a pointer.

func ErrNotNoRows

func ErrNotNoRows(title string, err error) errstack.E

ErrNotNoRows check if errors is not Nil and is not ErrNoRows

func ValidateSave

func ValidateSave(obj Validated, db *pg.DB) errstack.E

ValidateSave validates and save an object into DB.

Types

type DBSave

type DBSave interface {
	Save(db *pg.DB) errstack.E
}

DBSave is an interface for a domain entity which is able to save into DB.

type Validated

type Validated interface {
	Validate() errstack.Builder
}

Validated represents model entity which can be validated

Jump to

Keyboard shortcuts

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