models

package
v0.0.0-...-7f40e33 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRecord = errors.New("models: no matching record found")

Functions

This section is empty.

Types

type Snippet

type Snippet struct {
	ID      int
	Title   string
	Content string
	Created time.Time
	Expires time.Time
}

Snippet represents a snippet persisted to storage.

type SnippetModel

type SnippetModel struct {
	DB *sql.DB
}

SnippetModel wraps a sql.DB connection pool.

func (*SnippetModel) Get

func (m *SnippetModel) Get(id int) (Snippet, error)

Get will return a specific snippet based on its id.

func (*SnippetModel) Insert

func (m *SnippetModel) Insert(title string, content string, expires int) (int, error)

Insert will insert a new snippet into the database.

func (*SnippetModel) Latest

func (m *SnippetModel) Latest() ([]Snippet, error)

Latest will return the 10 most recently created snippets.

Jump to

Keyboard shortcuts

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