utilities

package
v0.0.0-...-c407d37 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExcludeDeletedScope

func ExcludeDeletedScope(models ...interface{}) pop.ScopeFunc

ExcludeDeletedScope is a chainable way to remove soft deleted models from your queries using Pop's Scope() command If you are filtering the same model that is being returned you can call this with no arguments and it should give you the desired behavior: db.Scope(utilities.ExcludedDeletedScope()).All(&mtoShipments).

If you are filtering on a join table(s) or need to disambiguate multiple tables with deleted_at columns, then you will need to pass in the model(s) so we can derive the real table names: db.Scope(utilities.ExcludeDeletedScope(models.MTOShipment{})).

Join("mto_shipments", "mto_shipments.move_id = moves.id").
All(&moves)

You won't be able to use this if you have given your table name(s) an alias, so just fall back to a normal where. You also cannot combine Scopes with RawQuery, which disregards any Join, Where, Scope, or Eager that may have been chained to the query.

https://gobuffalo.io/documentation/database/scoping/

func GetForeignKeyAssociations

func GetForeignKeyAssociations(c *pop.Connection, model interface{}) ([]interface{}, error)

GetForeignKeyAssociations fetches all the foreign key associations the model has

func GetHasManyForeignKeyAssociations

func GetHasManyForeignKeyAssociations(model interface{}) []interface{}

GetHasManyForeignKeyAssociations fetches the "has_many" foreing key association if not an empty model

func GetHasOneForeignKeyAssociation

func GetHasOneForeignKeyAssociation(model interface{}) interface{}

GetHasOneForeignKeyAssociation fetches the "has_one" foreign key association if not an empty model

func GetModelName

func GetModelName(model interface{}) string

GetModelName returns the name of the model

func IsModel

func IsModel(model interface{}) bool

IsModel verifies if the given interface is a model

func SoftDestroy

func SoftDestroy(c *pop.Connection, model interface{}) error

SoftDestroy soft deletes a record and all foreign key associations from the database

Types

This section is empty.

Jump to

Keyboard shortcuts

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