storage

package
v0.0.0-...-ff4c7c2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package storage implements the storage API used by the URL Shortener.

Index

Constants

This section is empty.

Variables

View Source
var Schema string

Functions

func IsErrConstraint

func IsErrConstraint(err error) bool

IsErrConstraint returns true if the passed err was created as the result of a constraint violation in the sqlite3 database.

func TestDB

func TestDB() *sql.DB

TestDB returns an in-memory sqlite3 database.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetLong

func (q *Queries) GetLong(ctx context.Context, short string) (string, error)

func (*Queries) SetShort

func (q *Queries) SetShort(ctx context.Context, arg SetShortParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type SetShortParams

type SetShortParams struct {
	Short string
	Longn string
}

type ShortLong

type ShortLong struct {
	Short string
	Longn string
}

Jump to

Keyboard shortcuts

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