Documentation ¶
Index ¶
- type DataSource
- type Postgres
- func (p *Postgres) CreateShortUrlTable() (sql.Result, error)
- func (p *Postgres) Init(dsn string, verbose bool)
- func (p *Postgres) InsertShortUrl(u ShortUrl) (result sql.Result, err error)
- func (p *Postgres) SelectAllShortUrl() (us []ShortUrl, err error)
- func (p *Postgres) SelectByOriginalUrl(oriurl string) (us ShortUrl, err error)
- func (p *Postgres) SelectByShortUrlCode(code string) (us ShortUrl, err error)
- type ShortUrl
- type Sqlite
- func (s *Sqlite) CreateShortUrlTable() (sql.Result, error)
- func (s *Sqlite) Init(dsn string, verbose bool) (err error)
- func (s *Sqlite) InsertShortUrl(u ShortUrl) (result sql.Result, err error)
- func (s *Sqlite) SelectAllShortUrl() (us []ShortUrl, err error)
- func (s *Sqlite) SelectByOriginalUrl(oriurl string) (us ShortUrl, err error)
- func (s *Sqlite) SelectByShortUrlCode(code string) (us ShortUrl, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataSource ¶
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func (*Postgres) InsertShortUrl ¶
InsertShortUrl inserts one record of short links in the database.
func (*Postgres) SelectAllShortUrl ¶
SelectAllShortUrl reads all short links records from the database.
func (*Postgres) SelectByOriginalUrl ¶
SelectByOriginalUrl selects the record by original URL in the database.
type Sqlite ¶
type Sqlite struct {
// contains filtered or unexported fields
}
func (*Sqlite) CreateShortUrlTable ¶
CreateShortUrlTable creates table in the database to store short links.
func (*Sqlite) Init ¶
InitSQLite initialize in-memory database to store data. The verbose flag indicates whether to print all queries to stdout.
func (*Sqlite) InsertShortUrl ¶
InsertShortUrl inserts one record of short links in the database.
func (*Sqlite) SelectAllShortUrl ¶
SelectAllShortUrl reads all short links records from the database.
func (*Sqlite) SelectByOriginalUrl ¶
SelectByOriginalUrl selects the record by original URL in the database.
Click to show internal directories.
Click to hide internal directories.