model

package
v0.0.0-...-5594105 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabase

func NewDatabase() *sql.DB

NewDatabase returns a new SQL database connection.

Types

type Paste

type Paste struct {
	ID               int64
	Title            string
	RawContent       string
	FormattedContent string
	IsPublic         bool
	Language         string
	TimeCreated      time.Time
	Duration         time.Duration
}

Paste represents the paste contents and surrounding metadata.

func (*Paste) MarshalBinary

func (paste *Paste) MarshalBinary() ([]byte, error)

MarshalBinary converts the paste to a binary array.

func (*Paste) UnmarshalBinary

func (paste *Paste) UnmarshalBinary(data []byte) error

UnmarshalBinary converts a binary array to paste.

type PasteStore

type PasteStore struct {
	// contains filtered or unexported fields
}

PasteStore is the store for pastes.

func NewPasteStore

func NewPasteStore(db *sql.DB) *PasteStore

NewPasteStore creates a new PasteStore instance.

func (*PasteStore) Delete

func (store *PasteStore) Delete(id int64) error

Delete deletes the paste with the given id from the database.

func (*PasteStore) Insert

func (store *PasteStore) Insert(paste *Paste) (*Paste, error)

Insert inserts a new paste to the database.

func (*PasteStore) SearchList

func (store *PasteStore) SearchList(filter string, limit int64, offset int64) ([]*Paste, error)

SearchList returns a list of public pastes sorted by their creation time and matching given filter.

func (*PasteStore) Select

func (store *PasteStore) Select(id int64) (*Paste, error)

Select returns the paste with the given id from the database.

func (*PasteStore) SelectList

func (store *PasteStore) SelectList(limit int64, offset int64) ([]*Paste, error)

SelectList returns a slice of public pastes sorted by their creation time.

type Scannable

type Scannable interface {
	Scan(dest ...interface{}) error
}

Scannable is a common interface for sql.Row and sql.Rows.

type User

type User struct {
	// Metadata
	ID                 int64
	TimeCreatedSeconds int64

	// Settings
	Name               string
	Mail               string
	AuthenticationType string
	PrivilegeLevel     string
	Theme              string
}

User represents a user.

Jump to

Keyboard shortcuts

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