model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CreateUser

func CreateUser(username, email string) error

func GenerateToken

func GenerateToken() string

func Init

func Init(c *config.Config) error

Types

type Bookmark

type Bookmark struct {
	CommonFields
	URL       string     `json:"url"`
	Title     string     `json:"title"`
	Notes     string     `json:"notes"`
	Domain    string     `json:"domain"`
	Favicon   string     `json:"favicon"`
	Tags      []Tag      `gorm:"many2many:bookmark_tags;" json:"tags"`
	Snapshots []Snapshot `json:"snapshots"`
	Public    bool       `json:"public"`
	UserID    uint       `json:"user_id"`
	User      User       `json:"-"`
}

type CommonFields added in v0.2.0

type CommonFields struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at"`
}

type Database added in v0.2.0

type Database struct {
	ID      uint `gorm:"primaryKey"`
	Version uint
}

type Resource added in v0.2.0

type Resource struct {
	CommonFields
	Key              string     `gorm:"unique" json:"key"`
	MimeType         string     `json:"mimeType"`
	OriginalFilename string     `json:"originalFilename"`
	Size             uint       `json:"size"`
	Snapshots        []Snapshot `gorm:"many2many:snapshot_resources;" json:"snapshots"`
}

func GetOrCreateResource added in v0.2.0

func GetOrCreateResource(key string, mimeType string, fname string, size uint) Resource

type Snapshot

type Snapshot struct {
	CommonFields
	Title      string     `json:"title"`
	Key        string     `json:"key"`
	Text       string     `json:"text"`
	BookmarkID uint       `json:"bookmark_id"`
	Size       uint       `json:"size"`
	Resources  []Resource `gorm:"many2many:snapshot_resources;" json:"resources"`
}

type Tag

type Tag struct {
	CommonFields
	Text      string     `gorm:"unique" json:"text"`
	Bookmarks []Bookmark `gorm:"many2many:bookmark_tags;" json:"bookmarks"`
}

func GetOrCreateTag added in v0.2.0

func GetOrCreateTag(tag string) Tag

type Token

type Token struct {
	CommonFields
	UserID uint   `json:"user_id"`
	Text   string `json:"text"`
}

type User

type User struct {
	CommonFields
	Username         string     `gorm:"unique" json:"username"`
	Email            string     `gorm:"unique" json:"email"`
	LoginToken       string     `json:"-"`
	SubmissionTokens []Token    `json:"-"`
	Bookmarks        []Bookmark `json:"bookmarks"`
}

func GetUser

func GetUser(name string) *User

func GetUserByLoginToken

func GetUserByLoginToken(tok string) *User

func GetUserBySubmissionToken

func GetUserBySubmissionToken(tok string) *User

Jump to

Keyboard shortcuts

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