Documentation ¶
Overview ¶
Package storage describes the interface for interacting with our datastore, and provides a PostgreSQL implementation for the slice-it-api.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Db ¶
Db provides a set of methods for interacting with our database.
func NewDB ¶
NewDB creates a connection with our postgres database and returns it, otherwise an error.
func (*Db) Create ¶
func (db *Db) Create(url SliceItURL) error
Create handles inserting a SliceItURL into the database. With no other requirements, we don't need to return anything but an error if it happens.
type SliceItURL ¶
type SliceItURL struct { ID int `json:"id,omitempty"` Short string `json:"short,omitempty"` Long string `json:"long,omitempty"` ViewCount int `json:"view_count,omitempty"` CreatedAt string `json:"created_at,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` }
SliceItURL represents a URL in in our system.
type URLRepository ¶
type URLRepository interface { Create(url SliceItURL) error Get(urlHash string) (string, error) GetViewCount(urlHash string) (int, error) }
URLRepository describes the interface for interacting with our datastore. This can viewed like a plug in adapter, making testing and/or switching datastores much more trivial.