models

package
v0.0.0-...-8fbaa3d Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clipboard

type Clipboard struct {
	ID       int
	Data     string
	HasFile  bool
	UserUUID string
}

Clipboard represents clipboard records from the database

type DB

type DB struct {
	*sql.DB
}

DB holds the database connection

func NewDB

func NewDB(dataSourceName string) (*DB, error)

NewDB instantiates a new database connection pool

func (*DB) AllClipboards

func (db *DB) AllClipboards(userUUID string) ([]*Clipboard, error)

AllClipboards returns all clipboards for a given user

func (*DB) CreateClipboard

func (db *DB) CreateClipboard(userUUID string, data string) (*Clipboard, error)

CreateClipboard does the following: * Create the new entry for the user * Trim the extra entries if user has more than 10 clipboards * Returns the new entry

func (*DB) CreateClipboardFile

func (db *DB) CreateClipboardFile(userUUID string, file io.Reader) (*Clipboard, error)

CreateClipboardFile does the following: * Create the new entry for the user with the file * Trim the extra entries if user has more than 10 clipboards * Returns the new entry

func (*DB) DeleteClipboard

func (db *DB) DeleteClipboard(userUUID string, cbID int) error

DeleteClipboard deletes the specified clipboard for the specified user

func (*DB) GetClipboardFile

func (db *DB) GetClipboardFile(userUUID string, cbID int) (io.Reader, error)

GetClipboardFile returns the file data associated with the specified clipboard and user

func (*DB) TrimEntries

func (db *DB) TrimEntries(userUUID string, tx *sql.Tx) error

type Datastore

type Datastore interface {
	AllClipboards() ([]*Clipboard, error)
}

Datastore is a generic interface to abstract the database

Jump to

Keyboard shortcuts

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