srm

package module
v0.0.0-...-4a94f85 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: Apache-2.0 Imports: 11 Imported by: 1

README

srm

Experimental idea for an ORM for GO

Documentation

Overview

SRM struct relation manager

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Scheme

func Scheme(typ IModel, defFn func(*scheme.Def)) *scheme.Def

Types

type IModel

type IModel interface {
	// contains filtered or unexported methods
}

IModel represents a struct containing a Model data

type Model

type Model struct {
	PrimaryKey string
}

Model holds database data, like relations, primary key

type Result

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

func (*Result) Fetch

func (r *Result) Fetch(target interface{}) error

func (*Result) FetchAll

func (r *Result) FetchAll(target interface{}) error

func (*Result) FetchNext

func (r *Result) FetchNext(target interface{}) bool

func (*Result) For

func (q *Result) For(i interface{}) error

func (*Result) NumOfRecords

func (r *Result) NumOfRecords() int

func (*Result) Select

func (q *Result) Select(fields ...string) *Result

type Session

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

AbstractDB holds a database context, an AbstractDB is responsible to operate on a database

func New

func New(driver driver.Driver) *Session

New returns a new database context

func (*Session) Begin

func (db *Session) Begin() error

Begin begins a transaction

func (*Session) Commit

func (db *Session) Commit() error

Commit all operations

func (*Session) Remove

func (db *Session) Remove(p IModel) error

Remove remove a model, will remove the model from de database

func (*Session) Retrieve

func (db *Session) Retrieve(m IModel, fields ...string) error

Retrieve retrieves a stored model or any decedent field specified by the fields ...key

func (*Session) RowBack

func (db *Session) RowBack() error

RowBack cancel all performed operations

func (*Session) Search

func (db *Session) Search(m IModel, q *query.Query) Result

Search search's for the records matching the specified query and returns the matching records in the result set

func (*Session) SearchAndModify

func (db *Session) SearchAndModify(s IModel, q *query.Query, changes ...change.Operation) (int, error)

SearchAndModify search's and modify the records matching the passed query expression with a list of changes passed as variadic list of operations

func (*Session) SearchAndRemove

func (db *Session) SearchAndRemove(s IModel, q *query.Query) (int, error)

SearchAndRemove search's and remove the records matching the passed query expression

func (*Session) Store

func (db *Session) Store(m IModel) (validation.Result, error)

Store stores a model into the database

func (*Session) Use

func (db *Session) Use(entityName string, model IModel) *scheme.Scheme

Use maps an entity name to a model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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