manager

package
v1.0.0-RC9 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityManager

type EntityManager interface {
	SetSchema(schema string) (sql.Result, error)
	Open(driver string, params string, schema string) error
	Close() error
	GetDBConnection() *sqlx.DB
	Migrate(i interface{}, autoCreate bool, dropIfExists bool) error
	DropTable(i interface{}) error
	Model(i interface{}) (metadata.GoedbTable, error)
	Insert(i interface{}) (GoedbResult, error)
	Update(i interface{}) (GoedbResult, error)
	Remove(i interface{}, where string, params map[string]interface{}) (GoedbResult, error)
	First(i interface{}, where string, params map[string]interface{}) error
	Find(i interface{}, where string, params map[string]interface{}) error
	NativeFirst(i interface{}, query string, params map[string]interface{}) error
	NativeFind(i interface{}, query string, params map[string]interface{}) error
	TxBegin() (*sql.Tx, error)
}

EntityManager is the manager used to interact with the database

type GoedbResult

type GoedbResult struct {
	NumRecordsAffected int64
	LastInsertId       int64
}

GoedbResult is the result for some operation in database

type GoedbSQLDriver

type GoedbSQLDriver struct {
	Dialect    dialect.Dialect
	Datasource config.Datasource
	// contains filtered or unexported fields
}

GoedbSQLDriver constains the database connection

func (*GoedbSQLDriver) Close

func (sqld *GoedbSQLDriver) Close() error

Close finishes the connection

func (*GoedbSQLDriver) DropTable

func (sqld *GoedbSQLDriver) DropTable(i interface{}) error

DropTable removes a table from the database

func (*GoedbSQLDriver) Find

func (sqld *GoedbSQLDriver) Find(resultEntitySlice interface{}, where string, params map[string]interface{}) error

Find returns all records found

func (*GoedbSQLDriver) First

func (sqld *GoedbSQLDriver) First(instance interface{}, where string, params map[string]interface{}) error

First returns the first record found

func (*GoedbSQLDriver) GetDBConnection

func (sqld *GoedbSQLDriver) GetDBConnection() *sqlx.DB

GetDBConnection returns the DB connection as *sqlx.DB. This method can be used if you wanna perform some query manually

func (*GoedbSQLDriver) Insert

func (sqld *GoedbSQLDriver) Insert(instance interface{}) (goedbres GoedbResult, err error)

Insert creates a new row with the object in the database (it must be migrated)

func (*GoedbSQLDriver) Migrate

func (sqld *GoedbSQLDriver) Migrate(i interface{}, autoCreate bool, dropIfExists bool) (err error)

Migrate creates the table in the database

func (*GoedbSQLDriver) Model

func (sqld *GoedbSQLDriver) Model(i interface{}) (metadata.GoedbTable, error)

Model returns the metadata of each structure migrated

func (*GoedbSQLDriver) NativeFind

func (sqld *GoedbSQLDriver) NativeFind(resultEntitySlice interface{}, sql string, params map[string]interface{}) error

NativeFind returns all records found

func (*GoedbSQLDriver) NativeFirst

func (sqld *GoedbSQLDriver) NativeFirst(instance interface{}, sql string, params map[string]interface{}) error

NativeFirst returns the first record found

func (*GoedbSQLDriver) Open

func (sqld *GoedbSQLDriver) Open(driver string, params string, schema string) error

Open creates the connection with the database **DON'T open a connection** This will be managed by goedb

func (*GoedbSQLDriver) Remove

func (sqld *GoedbSQLDriver) Remove(i interface{}, where string, params map[string]interface{}) (goedbres GoedbResult, err error)

Remove removes a row with the object in the database (it must be migrated)

func (*GoedbSQLDriver) SetSchema

func (sqld *GoedbSQLDriver) SetSchema(schema string) (sql.Result, error)

SetSchema sets the schema as default schema for a datasource

func (*GoedbSQLDriver) TxBegin

func (sqld *GoedbSQLDriver) TxBegin() (*sql.Tx, error)

TxBegin is used to set a transaction

func (*GoedbSQLDriver) Update

func (sqld *GoedbSQLDriver) Update(instance interface{}) (goedbres GoedbResult, err error)

Update updates an object using its primery key

Jump to

Keyboard shortcuts

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