models

package
v0.0.0-...-c7b99b7 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *pop.Connection

DB is a connection to your database to be used throughout your application.

Functions

func GetCounts

func GetCounts(tx *pop.Connection) (map[int]int, error)

func GetCountsForUser

func GetCountsForUser(tx *pop.Connection, u *User) (map[int]int, error)

Types

type Cap

type Cap struct {
	ID          uuid.UUID `json:"id" db:"id"`
	CreatedAt   time.Time `json:"created_at" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`
	Number      int       `json:"number" db:"number" form:"Number"`
	BelongsTo   *User     `json:"belongs_to,omitempty" belongs_to:"user"`
	BelongsToID uuid.UUID `json:"-" db:"userid"`
}

Cap is used by pop to map your .model.Name.Proper.Pluralize.Underscore database table to your go code.

func (*Cap) Create

func (cap *Cap) Create(tx *pop.Connection) (*validate.Errors, error)

func (Cap) String

func (c Cap) String() string

String is not required by pop and may be deleted

func (*Cap) Validate

func (c *Cap) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*Cap) ValidateCreate

func (c *Cap) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*Cap) ValidateUpdate

func (c *Cap) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type Caps

type Caps []Cap

Caps is not required by pop and may be deleted

type Field

type Field struct {
	ID        uuid.UUID  `json:"id" db:"id"`
	CreatedAt time.Time  `json:"created_at" db:"created_at"`
	UpdatedAt time.Time  `json:"updated_at" db:"updated_at"`
	Field     slices.Int `json:"field" db:"field"`
}

Field is used by pop to map your .model.Name.Proper.Pluralize.Underscore database table to your go code.

func (Field) Rows

func (f Field) Rows() [][]int

func (Field) String

func (f Field) String() string

String is not required by pop and may be deleted

func (*Field) Validate

func (f *Field) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*Field) ValidateCreate

func (f *Field) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*Field) ValidateUpdate

func (f *Field) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type Fields

type Fields []Field

Fields is not required by pop and may be deleted

type Group

type Group struct {
	ID        uuid.UUID `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	Name      string    `json:"name" db:"name"`
	Secret    string    `json:"secret" db:"secret"`

	InGroup []InGroup `json:"users" has_many:"ingroup"`
}

Group is used by pop to map your .model.Name.Proper.Pluralize.Underscore database table to your go code.

func (*Group) AddUser

func (g *Group) AddUser(userID uuid.UUID, admin bool)

func (*Group) Create

func (g *Group) Create(tx *pop.Connection) (*validate.Errors, error)

func (Group) String

func (g Group) String() string

String is not required by pop and may be deleted

func (*Group) Validate

func (g *Group) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*Group) ValidateCreate

func (g *Group) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*Group) ValidateUpdate

func (g *Group) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type Groups

type Groups []Group

Groups is not required by pop and may be deleted

func (Groups) String

func (g Groups) String() string

String is not required by pop and may be deleted

type InGroup

type InGroup struct {
	ID        uuid.UUID `json:"group_id" db:"id"`
	GroupID   uuid.UUID `json:"group_id" db:"group_id"`
	UserID    uuid.UUID `json:"user_id" db:"user_id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	IsAdmin   bool      `json:"is_admin" db:"is_admin"`

	User  *User  `json:"user,omitempty" belongs_to:"users"`
	Group *Group `json:"user,omitempty" belongs_to:"groups"`
}

func (InGroup) TableName

func (u InGroup) TableName() string

func (*InGroup) Validate

func (g *InGroup) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*InGroup) ValidateCreate

func (g *InGroup) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*InGroup) ValidateUpdate

func (g *InGroup) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type User

type User struct {
	ID             uuid.UUID `json:"id" db:"id"`
	CreatedAt      time.Time `json:"created_at" db:"created_at"`
	UpdatedAt      time.Time `json:"updated_at" db:"updated_at"`
	Email          string    `json:"email" db:"email"`
	PasswordHash   string    `json:"password_hash" db:"password_hash"`
	ValidationCode string    `json:"-" db:"validation_code"`
	Validated      bool      `json:"-" db:"validated"`

	Password             string `json:"-" db:"-"`
	PasswordConfirmation string `json:"-" db:"-"`

	Caps []Cap `json:"caps" has_many:"caps"`
}

User is a generated model from buffalo-auth, it serves as the base for username/password authentication.

func (*User) Create

func (u *User) Create(tx *pop.Connection) (*validate.Errors, error)

Create wraps up the pattern of encrypting the password and running validations. Useful when writing tests.

func (*User) SendValidationEmail

func (u *User) SendValidationEmail(tx *pop.Connection) error

Sends validation email

func (User) String

func (u User) String() string

String is not required by pop and may be deleted

func (*User) Validate

func (u *User) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.

func (*User) ValidateCreate

func (u *User) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)

ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.

func (*User) ValidateEmail

func (u *User) ValidateEmail(tx *pop.Connection) error

func (*User) ValidateUpdate

func (u *User) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)

ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.

type Users

type Users []User

Users is not required by pop and may be deleted

func (Users) String

func (u Users) String() string

String is not required by pop and may be deleted

Jump to

Keyboard shortcuts

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