database

package
v0.0.0-...-b7deca7 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sqlx.DB
}

func New

func New() (*DB, error)

New connects to the postgres database and returns the database instance.

func (*DB) CreateKey

func (db *DB) CreateKey(name string) (string, error)

CreateKey takes a name and creates for it a new row in the keys table.

func (*DB) GetKeys

func (db *DB) GetKeys() ([]Key, error)

GetKeys returns all the keys from the keys table.

func (*DB) RemoveKey

func (db *DB) RemoveKey(id int) error

RemoveKey takes an id and remove the row associated to it in the keys table.

type Key

type Key struct {
	Id        int       `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
	UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
	Name      string    `db:"name" json:"name"`
	Key       string    `db:"key" json:"key"`
}

Jump to

Keyboard shortcuts

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