model

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CreateAPFollower added in v0.4.0

func CreateAPFollower(uid uint, follower string) error

func CreateUser

func CreateUser(username, email string) error

func GenerateToken

func GenerateToken() string

func Init

func Init(c *config.Config) error

Types

type APFollower added in v0.4.0

type APFollower struct {
	CommonFields
	UserID   uint   `gorm:"uniqueIndex:uidx" json:"uid"`
	Follower string `gorm:"uniqueIndex:uidx" json:"follower"`
}

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"`
	CollectionID uint        `json:"-"`
	Collection   *Collection `json:"collection"`
	Public       bool        `json:"public"`
	UserID       uint        `json:"user_id"`
	User         User        `json:"-"`
}

func GetOrCreateBookmark added in v0.4.0

func GetOrCreateBookmark(u *User, urlString, title, tags, notes, public, favicon, collection string) (*Bookmark, bool, error)

TODO use Bookmark as parameter instead of strings

type Collection added in v0.5.0

type Collection struct {
	CommonFields
	Name      string `gorm:"uniqueIndex:cuid" json:"name"`
	UserID    uint   `gorm:"uniqueIndex:cuid" json:"user_id"`
	ParentID  uint
	Children  []*Collection `gorm:"foreignKey:parent_id"`
	User      User          `json:"-"`
	Bookmarks []Bookmark    `json:"bookmarks"`
}

func GetCollection added in v0.5.0

func GetCollection(uid uint, cid string) *Collection

func GetCollectionByName added in v0.5.0

func GetCollectionByName(uid uint, cname string) *Collection

func GetCollectionTree added in v0.5.0

func GetCollectionTree(uid uint) []*Collection

func GetCollections added in v0.5.0

func GetCollections(uid uint) []*Collection

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"`
	Bookmark   Bookmark   `json:"bookmark"`
	Size       uint       `json:"size"`
	Resources  []Resource `gorm:"many2many:snapshot_resources;" json:"resources"`
}

func GetSnapshotWithResources added in v0.5.0

func GetSnapshotWithResources(key string) (*Snapshot, error)

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 TagCount added in v0.4.0

type TagCount struct {
	Tag   string
	Count int64
}

func GetFrequentPublicTags added in v0.4.0

func GetFrequentPublicTags(count int) []*TagCount

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"`
	OAuthID          *string    `gorm:"unique" json:"-"`
	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 GetUserByOAuthID added in v0.3.0

func GetUserByOAuthID(id 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