models

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

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

Go to latest
Published: Aug 29, 2017 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	TGID      int64      `gorm:"primary_key" json:"chat_id"`
	CreatedAt time.Time  `json:"-"`
	DeletedAt *time.Time `json:"-"`
	Title     string     `json:"title"`
	Users     []User     `json:"-"`
	Images    []Image    `gorm:"ForeignKey:ChatID;AssociationForeignKey:TGID" json:"images,omitempty"`
	Tags      []Tag      `gorm:"many2many:chats_tags;AssociationForeignKey:ID;ForeignKey:TGID" json:"tags,omitempty"`
}

func (*Chat) CreateIfNotExists

func (ch *Chat) CreateIfNotExists(db *gorm.DB) error

func (*Chat) GetTags

func (ch *Chat) GetTags(db *gorm.DB) ([]Tag, error)

type Image

type Image struct {
	gorm.Model
	Src    string    `json:"src"`
	Tags   []Tag     `gorm:"many2many:images_tags" json:"tags,omitempty"`
	Date   time.Time `gorm:"not null" json:"date"`
	ChatID int64     `gorm:"not null" json:"chat_id"`
	Chat   Chat      `gorm:"ForeignKey:ChatID;AssociationForeignKey:TGID" json:"-"`
}

func (*Image) CreateImageWithTags

func (img *Image) CreateImageWithTags(db *gorm.DB, ts []Tag) error

func (*Image) GetImgByParams

func (img *Image) GetImgByParams(db *gorm.DB, params url.Values, user *User) ([]Image, error)

type Tag

type Tag struct {
	gorm.Model
	Name   string  `gorm:"not null; unique" json:"name"`
	Images []Image `gorm:"many2many:images_tags" json:"-"`
	Chats  []Chat  `gorm:"many2many:chats_tags" json:"-"`
}

func (*Tag) CreateIfUnique

func (t *Tag) CreateIfUnique(db *gorm.DB) error

type Token

type Token struct {
	gorm.Model
	Token     string    `gorm:"unique" json:"token"`
	ExpiredTo time.Time `json:"expired_to"`
	User      User      `gorm:"ForeignKey:UserID;AssociationForeignKey:TGID"`
	UserID    int       `json:"user_id"`
}

func (*Token) GetExpire

func (t *Token) GetExpire(db gorm.DB) time.Time

func (*Token) GetUserByToken

func (t *Token) GetUserByToken(db *gorm.DB) *User

func (*Token) Store

func (t *Token) Store(db *gorm.DB) error

type User

type User struct {
	TGID      int        `gorm:"primary_key" json:"-"`
	DeletedAt *time.Time `json:"-"`
	CreatedAt time.Time  `json:"-"`
	Username  string     `gorm:"size:64" json:"username"`
	Chats     []Chat     `gorm:"many2many:users_chats;AssociationForeignKey:TGID;ForeignKey:TGID"`
	Token     []Token    `gorm:"ForeignKey:ID;AssociationForeignKey:TGID"`
}

func (*User) CreateIfNotExists

func (u *User) CreateIfNotExists(db *gorm.DB) error

func (*User) GetTags

func (u *User) GetTags(db *gorm.DB) ([]Tag, error)

func (*User) GetUsersChats

func (u *User) GetUsersChats(db *gorm.DB) error

func (*User) IsExists

func (u *User) IsExists(db *gorm.DB) bool

func (*User) Register

func (u *User) Register(db *gorm.DB) (int64, error)

Jump to

Keyboard shortcuts

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