entities

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 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 struct {
	// contains filtered or unexported fields
}

EntityManager manages access to database with fluent statements using a database connection

func NewEntitymanager

func NewEntitymanager(connection *sql.DB, connectioninfo connection.IConnectionInfo) *EntityManager

NewEntitymanager - creates a new entitymanager

func (*EntityManager) Create

func (manager *EntityManager) Create(model *models.EntityModel) error

Create creates a new table or view for an entity in database. This is only to be used if the table does not exists already.

**Parameters**

  • model: model of entity to check for

func (*EntityManager) Exists

func (manager *EntityManager) Exists(model *models.EntityModel) (bool, error)

Exists determines whether an entity has a table or view in database

**Parameters**

  • model: model of entity to check for

**Returns**

  • bool: true if entity has a table or view in database
  • error: error information when database command resultet in error

func (*EntityManager) Insert

func (manager *EntityManager) Insert(model *models.EntityModel) *statements.InsertStatement

Insert creates an insert statement used to insert entity data into a database

**Parameters**

  • model: model of entity for which to insert data

**Returns**

  • InsertStatement: statement to use to prepare insert operation

func (*EntityManager) Load

func (manager *EntityManager) Load(model *models.EntityModel, fields ...interface{}) (*statements.LoadStatement, error)

Load creates a statement used to load data from the database

**Parameters**

  • model: model of entity for which to insert data
  • fields: specifies fields to load from database

**Returns**

  • LoadStatement: statement to use to prepare load operation

func (*EntityManager) LoadEntities

func (manager *EntityManager) LoadEntities(model *models.EntityModel) statements.ILoadEntityStatement

LoadEntities loads entities from the database

**Parameters**

  • model: model of entity for which to insert data

**Returns**

  • LoadEntityStatement: statement to use to prepare load entity operation

func (*EntityManager) Update

func (manager *EntityManager) Update(model *models.EntityModel) *statements.UpdateStatement

Update creates an update statement used to update entity data in the database

**Parameters**

  • model: model of entity of which to update data

**Returns**

  • *UpdateStatement: statement to use to prepare update operation

func (*EntityManager) UpdateSchema

func (manager *EntityManager) UpdateSchema(model *models.EntityModel) error

UpdateSchema updates the schema of an entity in database

**Parameters**

  • model: model of entity to update in database

**Returns**

  • error: error if any occured, nil otherwise

type IEntityManager

type IEntityManager interface {

	// loads entities from the database
	LoadEntities(model *models.EntityModel) statements.ILoadEntityStatement
}

IEntityManager - manages access to database with fluent statements

type SchemaUpdater

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

SchemaUpdater updates a schema in database

func (*SchemaUpdater) UpdateTable

func (updater *SchemaUpdater) UpdateTable(newmodel *models.EntityModel, oldschema *models.Table) error

UpdateTable updates a table in database

**Parameters**

  • newmodel: model of updated entity
  • oldmodel: schema of entity currently stored in database

**Result**

  • error: error if any occured

func (*SchemaUpdater) UpdateView

func (updater *SchemaUpdater) UpdateView(newmodel *models.EntityModel, oldschema *models.View) error

UpdateView updates a view in database

**Parameters**

  • newmodel: model of updated view
  • oldmodel: schema of view currently stored in database

**Result**

  • error: error if any occured

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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