database

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Description: Database interface for the url shortener

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(dbFilename string) *sql.DB

Types

type DbInterface

type DbInterface interface {
	SetDatabase(f string)
	SetupSchema(f string)
	GetUrlFromPath(path string) (Url, error)
	InsertUrl(url Url) error
}

type DbType

type DbType struct {
	Instance *sql.DB
	Errors   map[string]error
}
var Db DbType

Database Instance

func (*DbType) GetUrlFromPath

func (d *DbType) GetUrlFromPath(path string) (Url, error)

GetUrlFromPath returns a URL from the Database based on the path segment

func (*DbType) InsertUrl

func (d *DbType) InsertUrl(url Url) error

func (*DbType) SetDatabase

func (d *DbType) SetDatabase(db *sql.DB)

func (*DbType) SetupSchema

func (d *DbType) SetupSchema()

type Url

type Url struct {
	Id   int
	Path string // Path is the path segment corresponding to a stored URL
	Url  string
	Time string
}

URL struct for database operations

Jump to

Keyboard shortcuts

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