Documentation ¶
Index ¶
Constants ¶
View Source
const ( GetListRepositoryByOwnerQuery = `SELECT owner, name, private FROM repositories WHERE owner=$1` GetRepositoryQuery = `SELECT owner, name, private FROM repositories WHERE owner=$1 AND name=$2` CreateRepositoryQuery = `INSERT INTO repositories (owner, name, private) VALUES ($1, $2, $3) RETURNING id` DeleteRepositoryQuery = `DELETE FROM repositories WHERE owner=$1 and name=$2` )
Variables ¶
View Source
var IncorrectFullName = fmt.Errorf("incorrect full name for repository")
Functions ¶
func ConnectDatabase ¶
func ConnectDatabase(dbName string, opts ...*DatabaseOptions) (*sql.DB, error)
func CreateRepository ¶
func CreateRepository(runner SQLRunner, repo *Repository) (err error)
func DeleteRepository ¶
Types ¶
type DatabaseOptions ¶
type DatabaseOptions struct { // Host is PostgreSQL database host Host string // Port is PostgreSQL database port Port string // User is connection user User string // Password is connection password to authenticate with Password string }
DatabaseOptions is a configuration object type to pass PostgreSQL connection options.
func (*DatabaseOptions) ConnectionString ¶
func (opts *DatabaseOptions) ConnectionString() string
ConnectionString returns a connection string suitable to for sql.DB().
type Repository ¶
type Repository struct { ID int `json:"-"` Owner string `json:"owner"` Name string `json:"name"` Private bool `json:"private"` }
func GetListRepositoryByOwner ¶
func GetListRepositoryByOwner(runner SQLRunner, owner string) (repositories []Repository, err error)
func GetRepositoryByFullName ¶
func GetRepositoryByFullName(runner SQLRunner, fullName string) (*Repository, error)
func (*Repository) FullName ¶
func (repo *Repository) FullName() string
func (*Repository) MarshalJSON ¶
func (repo *Repository) MarshalJSON() ([]byte, error)
func (*Repository) Validate ¶
func (repo *Repository) Validate() error
Click to show internal directories.
Click to hide internal directories.