models

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package models extends the schema package for model management

Index

Constants

This section is empty.

Variables

View Source
var (
	// PersonCreateColumns columns only allowed in create
	PersonCreateColumns = boil.Greylist(
		schema.PersonColumns.Email,
		schema.PersonColumns.FirstName,
		schema.PersonColumns.LastName,
		schema.PersonColumns.MiddleName,
	)

	// PersonUpdateColumns columns only allowed in update
	PersonUpdateColumns = boil.Whitelist(
		schema.PersonColumns.Email,
		schema.PersonColumns.FirstName,
		schema.PersonColumns.LastName,
		schema.PersonColumns.MiddleName,
	)

	// PersonDeleteColumns columns only allowed in delete
	PersonDeleteColumns = boil.Whitelist(
		schema.PersonColumns.IsDeleted,
	)

	// PersonAllFields all fields that can be displayed
	PersonAllFields = []string{
		schema.PersonColumns.CreatedAt,
		schema.PersonColumns.Email,
		schema.PersonColumns.FirstName,
		schema.PersonColumns.ID,
		schema.PersonColumns.LastName,
		schema.PersonColumns.MiddleName,
		schema.PersonColumns.ModifiedAt,
	}
)

Functions

func StartUp added in v0.0.3

func StartUp() (err error)

StartUp loads all model dependencies

Types

type EmailExampleData added in v0.0.3

type EmailExampleData struct {
	Person
	SupportEmail string `json:"support_email"`
}

EmailExampleData is the email struct for the data

type Person

type Person struct {
	schema.Person
}

Person extends the schema model

func GetPersonByEmail

func GetPersonByEmail(email string) (person *Person, err error)

GetPersonByEmail gets a person by email address

func GetPersonByID

func GetPersonByID(id uint64) (person *Person, err error)

GetPersonByID gets a person by ID

func GetPersons

func GetPersons() (persons []Person, err error)

GetPersons gets an array of person //todo: temporary for now

func NewPerson

func NewPerson() *Person

NewPerson creates an empty person model

func NewPersonUsingSchema

func NewPersonUsingSchema(person schema.Person) *Person

NewPersonUsingSchema creates a person model using a schema

func NewPersonsUsingSchema

func NewPersonsUsingSchema(personSlice schema.PersonSlice) []Person

NewPersonsUsingSchema creates a new model using a schema

func (*Person) BeforeValidate

func (p *Person) BeforeValidate()

BeforeValidate runs before validate (sanitizing, formatting, default values)

func (*Person) Save

func (p *Person) Save(columns boil.Columns, tx *sql.Tx) (rowsAffected int64, err error)

Save either inserts or updates a model

func (*Person) SendExampleEmail added in v0.0.3

func (p *Person) SendExampleEmail(ctx context.Context) (err error)

SendExampleEmail sends an example email

func (*Person) Validate

func (p *Person) Validate() error

Validate checks the model, struct and any custom validations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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