models

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(n int) string

GenerateRandomString returns a random string with `n` as the length

func IsValid

func IsValid(tagName string, model interface{}) bool

IsValid checks if a `model` entry is valid, given the `tagName` (scope) for validation

Types

type Client

type Client struct {
	Model
	UUID   string `gorm:"not null;unique;index" validate:"omitempty,uuid4" json:"id"`
	Key    string `gorm:"not null;unique;index" json:"-"`
	Secret string `gorm:"not null" validate:"required" json:"-"`
}

Client is the client application model/struct

func (*Client) Authentic

func (client *Client) Authentic(secret string) bool

Authentic checks if a secret is valid for a given Client

func (*Client) BeforeCreate

func (client *Client) BeforeCreate(scope *gorm.Scope) error

BeforeCreate Client model/struct hook

func (*Client) BeforeSave

func (client *Client) BeforeSave(scope *gorm.Scope) error

BeforeSave Client model/struct hook

func (*Client) UpdateSecret

func (client *Client) UpdateSecret(secret string) error

UpdateSecret updates an Client's secret

type Model

type Model struct {
	ID        uint      `gorm:"primary_key" json:"-"`
	CreatedAt time.Time `gorm:"not null" json:"-"`
	UpdatedAt time.Time `json:"-"`
}

Model is the base model/struct for any model in the application/system

Jump to

Keyboard shortcuts

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