models

package
v0.0.0-...-71a6ebb Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertEntry

func InsertEntry(userID uint64, entry *Entry) error

InsertEntry saves a new Entry into the database.

func NamedInsert

func NamedInsert(query string, arg interface{}) (uint64, error)

NamedInsert executes the query insert statement and returns the generated sequence id.

func SetDB

func SetDB(adb *sqlx.DB)

SetDB sets the database connection.

func UpdateEntry

func UpdateEntry(entry *Entry) error

UpdateEntry updates a logbook entry in the database.

Types

type Entry

type Entry struct {
	ID        uint64         `db:"id" form:"id"`
	UUID      string         `db:"uuid" form:"uuid"`
	Title     string         `db:"title" form:"title"`
	URL       string         `db:"url" form:"url"`
	Notes     string         `db:"notes" form:"notes"`
	Private   bool           `db:"private" form:"private"`
	UserID    uint64         `db:"user_id"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
	Tags      pq.StringArray `db:"tags"`
	TSV       sql.RawBytes   `db:"tsv"`
}

An Entry is a URL and/or Notes.

func GetLogbook

func GetLogbook(userID uint64, tags []string, q []string, offset int, limit int) ([]*Entry, error)

GetLogbook returns a logged-in user's logbook.

func GetLogbookEntry

func GetLogbookEntry(userID uint64, entryUUID string) (Entry, error)

GetLogbookEntry returns an unique Entry by user id and entry uuid.

func GetUserPublicLogbook

func GetUserPublicLogbook(username string, tag string, offset int, limit int) ([]*Entry, error)

GetUserPublicLogbook returns an active user's public bookmarks.

func (*Entry) Validate

func (entry *Entry) Validate() error

Validate validates a Logbook Entry, returning an error if it is not valid.

type EntryExport

type EntryExport struct {
	Title     string         `db:"title"`
	URL       string         `db:"url"`
	Notes     string         `db:"notes"`
	Private   bool           `db:"private"`
	CreatedAt time.Time      `db:"created_at"`
	Tags      pq.StringArray `db:"tags"`
}

func GetAllLogbookEntries

func GetAllLogbookEntries(userID uint64) ([]*EntryExport, error)

type TagCount

type TagCount struct {
	Count uint64 `db:"count"`
	Tag   string `db:"tag"`
}

func GetTagCounts

func GetTagCounts(userID uint64) ([]*TagCount, error)

type User

type User struct {
	ID          uint64      `db:"id"`
	UUID        string      `db:"uuid"`
	UserName    string      `db:"username"`
	Password    string      `db:"password"`
	DisplayName string      `db:"display_name"`
	Active      bool        `db:"active"`
	CreatedAt   time.Time   `db:"created_at"`
	LastLoginAt pq.NullTime `db:"last_login_at"`
}

A User may log in to the site and create Entry records.

func Login

func Login(username string, password string) (User, error)

Login returns a User if the username and password match an existing user.

Jump to

Keyboard shortcuts

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