model

package
v0.0.0-...-6dc7df5 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Package model encapsulates account behavior.

Package model encapsulates backend behavior.

Package model encapsulates post behavior.

Package model encapsulates profile behavior.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Models ...
	// NOTE: order matters
	Models = []interface{}{
		&Account{},
		&Profile{},
		&Post{},
	}
)

Functions

func FromAccountToPayload

func FromAccountToPayload(account *Account, rsp *pbAccount.AccountPayload) error

FromAccountToPayload ...

func FromPayloadToAccount

func FromPayloadToAccount(rsp *pbAccount.AccountPayload, account *Account) error

FromPayloadToAccount ...

func FromPayloadToPost

func FromPayloadToPost(rsp *pbPost.PostPayload, post *Post) error

FromPayloadToPost ...

func FromPayloadToProfile

func FromPayloadToProfile(rsp *pbProfile.ProfilePayload, profile *Profile) error

FromPayloadToProfile ...

func FromPostToPayload

func FromPostToPayload(post *Post, rsp *pbPost.PostPayload) error

FromPostToPayload ...

func FromProfileToPayload

func FromProfileToPayload(profile *Profile, rsp *pbProfile.ProfilePayload) error

FromProfileToPayload ...

func GetSingletonBackend

func GetSingletonBackend() *gorm.DB

GetSingletonBackend ...

Types

type Account

type Account struct {
	gorm.Model
	Username  string
	Password  string
	ProfileID uint
	Profile   Profile
	Posts     []Post
}

Account ...

func (*Account) Create

func (a *Account) Create() error

Create ...

func (*Account) Delete

func (a *Account) Delete() error

Delete ...

func (*Account) Read

func (a *Account) Read() error

Read ...

func (*Account) SignIn

func (a *Account) SignIn() error

SignIn ...

func (*Account) SignOut

func (a *Account) SignOut() error

SignOut ...

func (*Account) SignUp

func (a *Account) SignUp() error

SignUp ...

func (*Account) Update

func (a *Account) Update() error

Update ...

type Model

type Model interface {
	Create() error
	Read() error
	Update() error
	Delete() error
}

Model ...

type Post

type Post struct {
	gorm.Model
	Title     string
	Content   string
	AccountID uint
}

Post ...

func (*Post) AfterSave

func (p *Post) AfterSave(tx *gorm.DB) error

AfterSave ...

func (*Post) Create

func (p *Post) Create() error

Create ...

func (*Post) Delete

func (p *Post) Delete() error

Delete ...

func (*Post) Read

func (p *Post) Read() error

Read ...

func (*Post) Update

func (p *Post) Update() error

Update ...

type Profile

type Profile struct {
	gorm.Model
	Name    string
	Surname string
	Age     uint32
	Gossip  uint32
}

Profile ...

func (*Profile) Create

func (p *Profile) Create() error

Create ...

func (*Profile) Delete

func (p *Profile) Delete() error

Delete ...

func (*Profile) Read

func (p *Profile) Read() error

Read ...

func (*Profile) Update

func (p *Profile) Update() error

Update ...

Jump to

Keyboard shortcuts

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