sqlstorage

package module
v0.0.0-...-9a160f8 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: BSD-3-Clause Imports: 16 Imported by: 0

README

sqlstorage: SQL storage

SQL databases generic CRUD system for Go.

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrItemConflict represents an item conflict error.
	ErrItemConflict = errors.New("item conflict")
	// ErrItemNotFound represents an item not found error.
	ErrItemNotFound = errors.New("item not found")
	// ErrMissingField represents a missing mandatory field error.
	ErrMissingField = errors.New("missing mandatory field")
	// ErrUnknownColumn represents an unknown column error.
	ErrUnknownColumn = errors.New("unknown column")
	// ErrUnknownReference represents an unknown reference error.
	ErrUnknownReference = errors.New("unknown reference")
	// ErrUnsupportedDriver represents an unsupported database driver error.
	ErrUnsupportedDriver = errors.New("unsupported driver")
)

Functions

func Drivers

func Drivers() []string

Drivers returns the list of supported storage drivers.

Types

type GlobModifier

type GlobModifier string

GlobModifier represents a glob pattern string modifier.

type RegexpModifier

type RegexpModifier string

RegexpModifier represents a regexp pattern string modifier.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage represents a storage instance.

func NewStorage

func NewStorage(name string, config *maputil.Map, log *logger.Logger) (*Storage, error)

NewStorage creates a new storage instance.

func (*Storage) AddForeignKey

func (s *Storage) AddForeignKey(v interface{}, field, dest, onDelete, onUpdate string) *Storage

AddForeignKey defines a new foreign key for a given item.

func (*Storage) Association

func (s *Storage) Association(v interface{}, fields ...string) *Storage

Association registers a new item association field.

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage database connection.

func (*Storage) Count

func (s *Storage) Count(v interface{}) (int, error)

Count returns the count of existing items from the storage.

func (*Storage) DB

func (s *Storage) DB() *gorm.DB

DB returns the internal database instance.

func (*Storage) Delete

func (s *Storage) Delete(v interface{}) error

Delete removes an existing item from the storage.

func (*Storage) Get

func (s *Storage) Get(column string, values interface{}, v interface{}, assoc bool) error

Get retrieves an existing item from the storage.

func (*Storage) List

func (s *Storage) List(v interface{}, filters map[string]interface{}, sort []string, offset, limit int,
	assoc bool) (int, error)

List retrieves a list of existing items from the storage.

func (*Storage) Migrate

func (s *Storage) Migrate(v ...interface{}) error

Migrate handles automatic migration of given item database models.

func (*Storage) Save

func (s *Storage) Save(v interface{}) error

Save stores a new item or modifies an existing item into the storage.

func (*Storage) Search

func (s *Storage) Search(values []interface{}, v interface{}, filters map[string]interface{}, sort []string, offset,
	limit int) (int, error)

Search searches for existing items given multiple types in the storage.

Jump to

Keyboard shortcuts

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