models

package
v0.0.0-...-5d86741 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 5 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
}

Define a Snippet type to hold the data for an individual snippet. Notice how the fields of the struct correspond to the fields in the database

type SnippetModel

type SnippetModel struct {
	DB  *pgxpool.Pool
	CTX context.Context
}

The snippet model will be responsible for interacting with the DB, like inserting, updating, deleting, etc

func (*SnippetModel) Get

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

func (*SnippetModel) Insert

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

func (*SnippetModel) Latest

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

Jump to

Keyboard shortcuts

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