Documentation
¶
Index ¶
- type EntityManager
- func (manager *EntityManager) Create(model *models.EntityModel) error
- func (manager *EntityManager) Delete(model *models.EntityModel) *statements.DeleteStatement
- func (manager *EntityManager) Exists(model *models.EntityModel) (bool, error)
- func (manager *EntityManager) Insert(model *models.EntityModel) *statements.InsertStatement
- func (manager *EntityManager) Load(model *models.EntityModel, fields ...interface{}) *statements.LoadStatement
- func (manager *EntityManager) LoadEntities(model *models.EntityModel) *statements.LoadStatement
- func (manager *EntityManager) Select(fields ...interface{}) *statements.LoadStatement
- func (manager *EntityManager) Transaction() (*sql.Tx, error)
- func (manager *EntityManager) Update(model *models.EntityModel) *statements.UpdateStatement
- func (manager *EntityManager) UpdateSchema(model *models.EntityModel) error
- type IEntityManager
- type SchemaUpdater
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) Delete ¶ added in v0.1.5
func (manager *EntityManager) Delete(model *models.EntityModel) *statements.DeleteStatement
Delete creates a delete statement used to remove entities from the database
**Parameters**
- model: model of entity of which to update data
**Returns**
- *DeleteStatement: statement to use to prepare delete operation
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
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.LoadStatement
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) Select ¶ added in v0.1.5
func (manager *EntityManager) Select(fields ...interface{}) *statements.LoadStatement
Select loads pure values from the database
**Parameters**
- fields: specifies fields to load from database
**Returns**
- LoadStatement: statement to use to prepare load operation
func (*EntityManager) Transaction ¶ added in v0.1.5
func (manager *EntityManager) Transaction() (*sql.Tx, error)
Transaction starts a transaction using the underlying db connection
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 {
// Transaction starts a transaction using the underlying db connection
Transaction() (*sql.Tx, error)
// loads entities from the database
LoadEntities(model *models.EntityModel) *statements.LoadStatement
// loads data from a table
Load(model *models.EntityModel, fields ...interface{}) *statements.LoadStatement
// inserts data into a table
Insert(model *models.EntityModel) *statements.InsertStatement
// updates data of a table
Update(model *models.EntityModel) *statements.UpdateStatement
// selects raw values from the database
Select(fields ...interface{}) *statements.LoadStatement
// deletes rows from a database
Delete(model *models.EntityModel) *statements.DeleteStatement
// updates schema of a table in database (or creates it)
UpdateSchema(model *models.EntityModel) error
}
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