store

package
v0.0.0-...-bac1ed6 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bookmark

type Bookmark struct {
	ID          string     `gorm:"primary_key;TYPE:varchar(255);COLUMN:id"`
	Path        string     `gorm:"TYPE:varchar(255);COLUMN:path;NOT NULL;INDEX:IX_PATH;INDEX:IX_PATH_USER"`
	DisplayName string     `gorm:"TYPE:varchar(128);COLUMN:display_name;NOT NULL"`
	URL         string     `gorm:"TYPE:varchar(512);COLUMN:url;NOT NULL;INDEX:IX_SORT_ORDER"`
	SortOrder   int        `gorm:"COLUMN:sort_order;DEFAULT:0;NOT NULL"`
	Type        NodeType   `gorm:"COLUMN:type;DEFAULT:0;NOT NULL"`
	UserName    string     `gorm:"TYPE:varchar(128);COLUMN:user_name;NOT NULL;INDEX:IX_USER;INDEX:IX_PATH_USER"`
	Created     time.Time  `gorm:"COLUMN:created;NOT NULL"`
	Modified    *time.Time `gorm:"COLUMN:modified"`
	ChildCount  int        `gorm:"COLUMN:child_count;DEFAULT:0;NOT NULL"`
	AccessCount int        `gorm:"COLUMN:access_count;DEFAULT:0;NOT NULL"`
	Favicon     string     `gorm:"TYPE:varchar(128);COLUMN:favicon;NOT NULL"`
}

Bookmark maps the database table to a struct

func (Bookmark) String

func (b Bookmark) String() string

func (Bookmark) TableName

func (Bookmark) TableName() string

TableName specifies the name of the Table used

type NodeCount

type NodeCount struct {
	Path  string
	Count int
}

NodeCount displays the number of child-elements for a given path (1 level)

type NodeType

type NodeType int
const (
	Node NodeType = iota
	Folder
)

type Repository

type Repository interface {
	InUnitOfWork(fn func(repo Repository) error) error
	Create(item Bookmark) (Bookmark, error)
	Update(item Bookmark) (Bookmark, error)
	Delete(item Bookmark) error
	DeletePath(path, username string) error

	GetAllBookmarks(username string) ([]Bookmark, error)
	GetBookmarksByPath(path, username string) ([]Bookmark, error)
	GetBookmarksByPathStart(path, username string) ([]Bookmark, error)
	GetBookmarksByName(name, username string) ([]Bookmark, error)
	GetMostRecentBookmarks(username string, limit int) ([]Bookmark, error)
	GetPathChildCount(path, username string) ([]NodeCount, error)
	GetAllPaths(username string) ([]string, error)

	GetBookmarkById(id, username string) (Bookmark, error)
	GetFolderByPath(path, username string) (Bookmark, error)
}

Repository defines methods to interact with a store

func Create

func Create(db *gorm.DB) Repository

Create a new repository

Jump to

Keyboard shortcuts

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