models

package
v0.0.0-...-e724b53 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NumUsers

func NumUsers(tx *sqlx.Tx) (int, error)

NumUsers returns the number of users in the users table.

Types

type Bookmark

type Bookmark struct {
	ID       int64
	UserID   *int64 `db:"user_id"`
	Title    string
	URL      string
	Tags     []string `db:"-"`
	TagsText string   `db:"tags" json:"-"` // Tags converted to string, for storing into sqlite.
	Notes    string
	Updated  time.Time
}

Bookmark datatype

func BookmarkByID

func BookmarkByID(id int64, tx *sqlx.Tx) (*Bookmark, error)

BookmarkByID returns a Bookmark by ID.

func BookmarkByURL

func BookmarkByURL(url string, tx *sqlx.Tx) (*Bookmark, error)

BookmarkByURL returns all bookmark with matching URL, or nil.

func BookmarksAllForUser

func BookmarksAllForUser(userID int64, orderBy string, tx *sqlx.Tx) ([]*Bookmark, error)

BookmarksAllForUser returns all bookmarks owned by a user or not owned by anone (user is NULL).

func NewBookmark

func NewBookmark(title, url, notes string, tags []string) *Bookmark

NewBookmark creates a new bookmark with ID -1.

func (*Bookmark) CleanTags

func (bm *Bookmark) CleanTags()

CleanTags cleans up the tags to a list separated by commas.

func (*Bookmark) Delete

func (bm *Bookmark) Delete(tx *sqlx.Tx) error

Delete deletes a bookmark from the database.

func (*Bookmark) Insert

func (bm *Bookmark) Insert(tx *sqlx.Tx) error

Insert a bookmark into the database.

func (*Bookmark) Update

func (bm *Bookmark) Update(tx *sqlx.Tx) error

Update a bookmark in the database.

type User

type User struct {
	ID       int64
	Name     string
	Password string
	Admin    bool
}

User account

func NewUser

func NewUser(name, password string, admin bool, pwSecret string) (*User, error)

NewUser creates a new user object.

func UserByID

func UserByID(id int64, tx *sqlx.Tx) (*User, error)

UserByID returns a user object by id. Returns error if not found.

func UserByName

func UserByName(name string, tx *sqlx.Tx) (*User, error)

UserByName returns a user object by username.

func (*User) Insert

func (u *User) Insert(tx *sqlx.Tx) error

Insert a user into the database.

func (*User) Update

func (u *User) Update(tx *sqlx.Tx) error

Update a user in the database.

Jump to

Keyboard shortcuts

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