models

package
v0.0.0-...-9d17cf8 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Avatar

type Avatar struct {
	File binding.File `db:"-" form:"avatar"`
}

type Categories

type Categories []Category

Categories is not required by pop and may be deleted

func (Categories) Len

func (p Categories) Len() int

func (Categories) Less

func (p Categories) Less(i, j int) bool

func (Categories) String

func (c Categories) String() string

String is not required by pop and may be deleted

func (Categories) Swap

func (p Categories) Swap(i, j int)

type Category

type Category 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"`
	Title          string       `json:"title" db:"title"`
	Description    nulls.String `json:"description" db:"description"`
	ParentCategory nulls.UUID   `json:"parent_category" db:"parent_category"`
	Subscribers    slices.UUID  `json:"subscribers" db:"subscribers"`
}

func (*Category) AddSubscriber

func (c *Category) AddSubscriber(id uuid.UUID)

func (*Category) RemoveSubscriber

func (c *Category) RemoveSubscriber(id uuid.UUID)

func (Category) String

func (c Category) String() string

String is not required by pop and may be deleted

func (*Category) Validate

func (c *Category) 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 (*Category) ValidateCreate

func (c *Category) 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 (*Category) ValidateUpdate

func (c *Category) 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 EmailNotTaken

type EmailNotTaken struct {
	Name  string
	Field string
	// contains filtered or unexported fields
}

func (*EmailNotTaken) IsValid

func (v *EmailNotTaken) IsValid(errors *validate.Errors)

IsValid performs the validation check for unique emails

type Forum

type Forum 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"`
	Title       string    `json:"title" db:"title"`
	Description string    `json:"description" db:"description"`
}

func (Forum) LogoImage

func (f Forum) LogoImage() string

func (Forum) String

func (f Forum) String() string

String is not required by pop and may be deleted

func (*Forum) Validate

func (f *Forum) 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 (*Forum) ValidateCreate

func (f *Forum) 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 (*Forum) ValidateUpdate

func (f *Forum) 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 Forums

type Forums []Forum

Forums is not required by pop and may be deleted

func (Forums) String

func (f Forums) String() string

String is not required by pop and may be deleted

type Replies

type Replies []Reply

func (Replies) Len

func (p Replies) Len() int

func (Replies) Less

func (p Replies) Less(i, j int) bool

func (Replies) Swap

func (p Replies) Swap(i, j int)

type Reply

type Reply 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"`
	AuthorID  uuid.UUID `json:"author_id" db:"author_id"`
	TopicID   uuid.UUID `json:"topic_id" db:"topic_id"`
	Content   string    `json:"content" db:"content"`
	Deleted   bool      `json:"deleted" db:"deleted"`

	Author *User  `json:"-" db:"-"`
	Topic  *Topic `json:"-" db:"-"`
}

func (*Reply) Validate

func (p *Reply) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.

type Topic

type Topic 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"`
	Title       string      `json:"title" db:"title"`
	Content     string      `json:"content" db:"content"`
	AuthorID    uuid.UUID   `json:"author_id" db:"author_id"`
	CategoryID  uuid.UUID   `json:"category_id" db:"category_id"`
	Deleted     bool        `json:"deleted" db:"deleted"`
	Subscribers slices.UUID `json:"subscribers" db:"subscribers"`

	Author   *User     `json:"-" db:"-"`
	Category *Category `json:"-" db:"-"`
	Replies  Replies   `json:"-" db:"-"`
}

func (*Topic) AddSubscriber

func (t *Topic) AddSubscriber(id uuid.UUID)

func (Topic) Authors

func (t Topic) Authors() Users

func (Topic) LastUpdate

func (t Topic) LastUpdate() time.Time

func (*Topic) RemoveSubscriber

func (t *Topic) RemoveSubscriber(id uuid.UUID)

func (Topic) Subscribed

func (t Topic) Subscribed(id uuid.UUID) bool

func (*Topic) Validate

func (p *Topic) Validate(tx *pop.Connection) (*validate.Errors, error)

Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.

type Topics

type Topics []Topic

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"`
	Username        string      `json:"username" db:"username"`
	Email           string      `json:"email" db:"email"`
	PasswordHash    string      `json:"-" db:"password_hash"`
	Password        string      `json:"-" db:"-"`
	PasswordConfirm string      `json:"-" db:"-"`
	FullName        string      `json:"full_name" db:"full_name" form:"full_name"`
	Avatar          []byte      `json:"avatar" db:"avatar"`
	Admin           bool        `json:"admin" db:"admin"`
	Subscriptions   slices.UUID `json:"subscriptions" db:"subscriptions"`
}

func (*User) AddSubscription

func (u *User) AddSubscription(id uuid.UUID)

func (*User) Authorize

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

Authorize checks user's password for logging in

func (*User) Create

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

Create validates and creates a new User.

func (User) Image

func (u User) Image() string

func (User) IsAuthor

func (u User) IsAuthor(id uuid.UUID) bool

func (*User) RemoveSubscription

func (u *User) RemoveSubscription(id uuid.UUID)

func (User) String

func (u User) String() string

String is not required by pop and may be deleted

func (User) Subscribed

func (u User) Subscribed(id uuid.UUID) bool

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) 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 UsernameIsLowerCase

type UsernameIsLowerCase struct {
	Name  string
	Field string
	// contains filtered or unexported fields
}

func (*UsernameIsLowerCase) IsValid

func (v *UsernameIsLowerCase) IsValid(errors *validate.Errors)

type UsernameNotTaken

type UsernameNotTaken struct {
	Name  string
	Field string
	// contains filtered or unexported fields
}

func (*UsernameNotTaken) IsValid

func (v *UsernameNotTaken) IsValid(errors *validate.Errors)

type Users

type Users []User

Users is not required by pop and may be deleted

func (Users) Len

func (p Users) Len() int

func (Users) Less

func (p Users) Less(i, j int) bool

func (Users) String

func (u Users) String() string

String is not required by pop and may be deleted

func (Users) Swap

func (p Users) Swap(i, j int)

Jump to

Keyboard shortcuts

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