database

package
v0.0.0-...-cdd45d8 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageNormal = iota
	MessageImage
	MessageFile
)
View Source
const (
	TokenAuthentication = iota
	TokenResetPassword
	TokenVerification
)

Variables

This section is empty.

Functions

func SetupDatabase

func SetupDatabase() *gorm.DB

Connect to the database and create the schema

Types

type Chat

type Chat struct {
	gorm.Model  `json:"-"`
	DisplayName string    `json:"name"`
	UUID        string    `json:"uuid"`
	Users       []User    `json:"users" gorm:"many2many:user_chats"`
	Messages    []Message `json:"messages" gorm:"foreignkey:ChatId"`
}

Stores user chat information

type File

type File struct {
	gorm.Model `json:"-"`
	Path       string `json:"-"`
	Filename   string `json:"filename"`
	UUID       string `json:"uuid"`
	Used       bool   `json:"used"`
	ChatId     uint   `json:"-"`
}

Stores file information related to messages

type Message

type Message struct {
	gorm.Model `json:"-"`
	ChatId     uint   `json:"-"`
	SenderId   uint   `json:"-"`
	Sender     User   `json:"sender" gorm:"foreignkey:SenderId"`
	Type       uint   `json:"type"`
	Message    string `json:"message"`
	File       *File  `json:"file" gorm:"foreignkey:FileId"`
	FileId     uint   `json:"-"`
	Timestamp  int64  `json:"timestamp"`
}

Stores user message information

type Token

type Token struct {
	gorm.Model
	SigningKey string
	Type       uint
	UserId     uint
	User       User
}

Store authentication tokens returned from login

type User

type User struct {
	gorm.Model `json:"-"`
	Name       string `json:"name"`
	Email      string `json:"email"`
	Username   string `json:"username"`
	Password   string `json:"-"`
	Chats      []Chat `json:"-" gorm:"many2many:user_chats"`
	Verified   bool   `json:"verified"`
}

Store user login information

Jump to

Keyboard shortcuts

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