hooks

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package hooks contains callbacks/hooks used by ngorm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterAssociation

func AfterAssociation(e *engine.Engine) error

AfterAssociation saves associations on the model

func AfterCreate

func AfterCreate(e *engine.Engine) error

AfterCreate executes hooks after Creating records

func AfterQuery

func AfterQuery(e *engine.Engine) error

AfterQuery executes any call back after the Query hook has been executed. Any callback registered with key model.HookQueryAfterFind will be executed.

func AfterUpdate

func AfterUpdate(e *engine.Engine) error

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

func AssignUpdatingAttrs(e *engine.Engine) error

AssignUpdatingAttrs assigns value for the attributes that are supposed to be updated.

func BeforeDelete

func BeforeDelete(e *engine.Engine) error

BeforeDelete is called before deleting any record

func BeforeUpdate

func BeforeUpdate(e *engine.Engine) error

BeforeUpdate handles preparations for updating records. This just calls two hooks.

model.HookBeforeSave

If this hook succeeds then It calls

model.HookBeforeUpdate

func ColumnAsScope

func ColumnAsScope(e *engine.Engine, column string) (*engine.Engine, error)

ColumnAsScope returnsnew Engine withthe value of the column used asscope.

func Create

func Create(e *engine.Engine) error

Create the hook executed to create a new record.

func CreateExec

func CreateExec(e *engine.Engine) error

CreateExec executes the INSERT query and assigns primary key if it is not set assuming the primary key is the ID field.

func CreateSQL

func CreateSQL(e *engine.Engine) error

CreateSQL generates SQL for creating new record

func Delete

func Delete(e *engine.Engine) error

Delete deletes records. This makes sure to call BeforeDelete hook before deleting anything and also calls AfterDelete before exiting.

func DeleteSQL

func DeleteSQL(e *engine.Engine) error

DeleteSQL generatesSQL for deleting records.

func JoinWith

func JoinWith(e *engine.Engine, s, handler *model.JoinTableHandler, source interface{}) (*engine.Engine, error)

JoinWith does sql join

func Preload

func Preload(e *engine.Engine) error

Preload executes preload conditions.

func PreloadBelongsTo

func PreloadBelongsTo(e *engine.Engine, field *model.Field, conditions []interface{}) error

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

func PreloadHasMany(e *engine.Engine, field *model.Field, conditions []interface{}) error

PreloadHasMany preloads has_many relation

func PreloadHasOne

func PreloadHasOne(e *engine.Engine, field *model.Field, conditions []interface{}) error

PreloadHasOne preloads has_one relation

func PreloadManyToMany

func PreloadManyToMany(e *engine.Engine, field *model.Field, conditions []interface{}) error

PreloadManyToMany preloads many_to_many relation

func QLAfterCreate

func QLAfterCreate(e *engine.Engine) error

QLAfterCreate hook executed after a new record has been created. This is for ql dialect use only.

func Query

func Query(e *engine.Engine) error

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

func QueryExec(e *engine.Engine) error

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

func QuerySQL(e *engine.Engine) error

QuerySQL generates SQL for queries. This uses `builder.PrepareQuery` to build the desired SQL query.

func SaveBeforeAssociation

func SaveBeforeAssociation(e *engine.Engine) error

SaveBeforeAssociation saves associations on the model

func Update

func Update(e *engine.Engine) error

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

func UpdateExec(e *engine.Engine) error

UpdateExec executes UPDATE sql. This assumes the query is already in e.Scope.SQL.

func UpdateSQL

func UpdateSQL(e *engine.Engine) error

UpdateSQL builds query for updating records.

func UpdateTimestamp

func UpdateTimestamp(e *engine.Engine) error

UpdateTimestamp sets the value of UpdatedAt field.

Types

This section is empty.

Jump to

Keyboard shortcuts

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