models

package
v0.0.0-...-8fd38ff Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Thing

type Thing struct {
	ID        string `gorm:"primary_key:true"`
	Title     string `json:"title"`
	Amount    int    `json:"amount"`
	CreatedAt time.Time
	UpdatedAt time.Time

	// This is a pointer so's a nil value can be returned
	// Gorm by default checks DeletedAt, so unless nil is
	// returned, a blank time will always be checked,
	// resulting in 0 results.
	DeletedAt *time.Time
}

Thing - Thing model

func (*Thing) BeforeCreate

func (thing *Thing) BeforeCreate(scope *gorm.Scope) error

BeforeCreate - Lifecycle callback - Generate UUID before persisting

type ThingRepository

type ThingRepository struct {
	// contains filtered or unexported fields
}

ThingRepository - Repository object for `things`

func NewThingRepository

func NewThingRepository(db *gorm.DB) *ThingRepository

NewThingRepository - Create a new instance of `ThingRepository` database instance injected

func (*ThingRepository) FindAll

func (repository *ThingRepository) FindAll() ([]Thing, error)

FindAll - Find all of the things

func (*ThingRepository) Insert

func (repository *ThingRepository) Insert(thing Thing) error

Insert - Create a thing

Jump to

Keyboard shortcuts

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