strategy

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 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 EagerLoading

type EagerLoading struct {
}

func (EagerLoading) All

func (e EagerLoading) All(res interface{}, scope *orm.Scope, c *sqlquery.Condition) error

All request all rows by the given condition. All foreign keys are collected after the main select, all relations are handled by one request (m2m has 2 selects one for the join table and one for the main data). The data is mapped after that. TODO back-references end in an infinity loop error at the moment TODO better solution of defer in a for loop, func? TODO defer in loop?

func (EagerLoading) Create

func (e EagerLoading) Create(scope *orm.Scope) error

Create an entry. BelongsTo relation is handled before the main entry. If the belongsTo primary already exists in the database it will be updated instead of created. Autoincrement field will be skipped if the value is zero. Last inserted ID will be set to the struct later on. Error will return if no columns of the root struct have any value. Relations are skipped if the value is zero. HasOne - entries are created only. There is no check if the ID already exists in the db. HasMany - if no other relations exists on that orm, a batch insert can be made because the inserted ID is not required. Otherwise a create will be called for every entry. No update or db check is been made. (TODO Callbacks must be handeldt both ways) ManyToMany - if the ID exists in the db, its been updated otherwise its been created. the join table is batched.

func (EagerLoading) Delete

func (e EagerLoading) Delete(scope *orm.Scope, c *sqlquery.Condition) error

func (EagerLoading) First

func (e EagerLoading) First(scope *orm.Scope, c *sqlquery.Condition, perm orm.Permission) error

First requests one row by the given condition. Relation hasOne and belongsTo will call orm First(). Relation hasMany and manyToMany will call orm All(). TODO: Custom relation conditions have to be improved, atm only depth 1.

func (EagerLoading) Update

func (e EagerLoading) Update(scope *orm.Scope, c *sqlquery.Condition) error

Jump to

Keyboard shortcuts

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