Documentation ¶
Overview ¶
Package hooks contains callbacks/hooks used by ngorm.
Index ¶
- func AfterAssociation(e *engine.Engine) error
- func AfterCreate(e *engine.Engine) error
- func AfterQuery(e *engine.Engine) error
- func AfterUpdate(e *engine.Engine) error
- func AssignUpdatingAttrs(e *engine.Engine) error
- func BeforeDelete(e *engine.Engine) error
- func BeforeUpdate(e *engine.Engine) error
- func ColumnAsScope(e *engine.Engine, column string) (*engine.Engine, error)
- func Create(e *engine.Engine) error
- func CreateExec(e *engine.Engine) error
- func CreateSQL(e *engine.Engine) error
- func Delete(e *engine.Engine) error
- func DeleteSQL(e *engine.Engine) error
- func JoinWith(e *engine.Engine, s, handler *model.JoinTableHandler, source interface{}) (*engine.Engine, error)
- func Preload(e *engine.Engine) error
- func PreloadBelongsTo(e *engine.Engine, field *model.Field, conditions []interface{}) error
- func PreloadDBWithConditions(e *engine.Engine, conditions []interface{}) (*engine.Engine, []interface{})
- func PreloadHasMany(e *engine.Engine, field *model.Field, conditions []interface{}) error
- func PreloadHasOne(e *engine.Engine, field *model.Field, conditions []interface{}) error
- func PreloadManyToMany(e *engine.Engine, field *model.Field, conditions []interface{}) error
- func QLAfterCreate(e *engine.Engine) error
- func Query(e *engine.Engine) error
- func QueryExec(e *engine.Engine) error
- func QuerySQL(e *engine.Engine) error
- func SaveBeforeAssociation(e *engine.Engine) error
- func Update(e *engine.Engine) error
- func UpdateExec(e *engine.Engine) error
- func UpdateSQL(e *engine.Engine) error
- func UpdateTimestamp(e *engine.Engine) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterAssociation ¶
AfterAssociation saves associations on the model
func AfterCreate ¶
AfterCreate executes hooks after Creating records
func AfterQuery ¶
AfterQuery executes any call back after the Query hook has been executed. Any callback registered with key model.HookQueryAfterFind will be executed.
func AfterUpdate ¶
AfterUpdate handles things needed to be done after updating records. This just calls two hooks
model.HookAfterUpdate
If this hook succeeds then It calls
model.HookAfterSave
func AssignUpdatingAttrs ¶
AssignUpdatingAttrs assigns value for the attributes that are supposed to be updated.
func BeforeDelete ¶
BeforeDelete is called before deleting any record
func BeforeUpdate ¶
BeforeUpdate handles preparations for updating records. This just calls two hooks.
model.HookBeforeSave
If this hook succeeds then It calls
model.HookBeforeUpdate
func ColumnAsScope ¶
ColumnAsScope returnsnew Engine withthe value of the column used asscope.
func CreateExec ¶
CreateExec executes the INSERT query and assigns primary key if it is not set assuming the primary key is the ID field.
func Delete ¶
Delete deletes records. This makes sure to call BeforeDelete hook before deleting anything and also calls AfterDelete before exiting.
func JoinWith ¶
func JoinWith(e *engine.Engine, s, handler *model.JoinTableHandler, source interface{}) (*engine.Engine, error)
JoinWith does sql join
func PreloadBelongsTo ¶
PreloadBelongsTo preloads belongs_to relationship
func PreloadDBWithConditions ¶
func PreloadDBWithConditions(e *engine.Engine, conditions []interface{}) (*engine.Engine, []interface{})
PreloadDBWithConditions returns engine with preload conditions set
func PreloadHasMany ¶
PreloadHasMany preloads has_many relation
func PreloadHasOne ¶
PreloadHasOne preloads has_one relation
func PreloadManyToMany ¶
PreloadManyToMany preloads many_to_many relation
func QLAfterCreate ¶
QLAfterCreate hook executed after a new record has been created. This is for ql dialect use only.
func Query ¶
Query executes sql Query without transaction. This first executes QuerySQL which generates appropriate SQl query then QueryExec hook is executed to execute the generated query.
If all is well HookAfterQuery is executed, if this hook is not registered then no error is returned.
func QueryExec ¶
QueryExec executes SQL queries and scans the result to the pointer object that is in e.Scope.Value.
The value stored in e.Scope.Value can only either be a struct or a slice other types are not supported.
NOTE: queries are not executed in transaction context.
func QuerySQL ¶
QuerySQL generates SQL for queries. This uses `builder.PrepareQuery` to build the desired SQL query.
func SaveBeforeAssociation ¶
SaveBeforeAssociation saves associations on the model
func Update ¶
Update generates and executes sql query for updating records.This relies on two hooks.
model.HookUpdateSQL
Which generates the sql for UPDATE
model.HookUpdateExec
which executes the UPDATE sql.
func UpdateExec ¶
UpdateExec executes UPDATE sql. This assumes the query is already in e.Scope.SQL.
func UpdateTimestamp ¶
UpdateTimestamp sets the value of UpdatedAt field.
Types ¶
This section is empty.