db

package
v0.0.0-...-cf6a8c0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomString

func GenerateRandomString(alphabet string, length int) (string, error)

GenerateRandomString returns a securely generated random string. Returns error on failure.

func GenerateSlug

func GenerateSlug() string

GenerateRandomString returns a securely generated random string suitable for use as a URL slug. Calls log.Fatal on failure.

Types

type BabyStruct

type BabyStruct struct {
	Id           int64
	Slug         string
	Name         string
	BirthDate    string `db:"birth_date"` // TODO do custom type http://jmoiron.net/blog/built-in-interfaces
	CreatedAt    string `db:"created_at"` // // TODO custom type
	Timezone     sql.NullString
	ClientInfoId sql.NullInt64 `db:"client_info_id"`
}

type ClientInfo

type ClientInfo struct {
	Id        int64
	UserAgent string
	IpAddress string
	CreatedAt string `db:"created_at"` // TODO custom type
}

type Connection

type Connection struct {
	*sqlx.DB
}

func NewConnection

func NewConnection(filename string) *Connection

func (*Connection) AddWord

func (c *Connection) AddWord(babyId int64, word string, learnedDate string) (int64, error)

func (*Connection) CreateBaby

func (c *Connection) CreateBaby(name string, birth_date string) (*BabyStruct, error)

func (*Connection) GetBaby

func (c *Connection) GetBaby(slug string) (*BabyStruct, error)

func (*Connection) ListWords

func (c *Connection) ListWords(babyId int64) ([]WordInfo, error)

func (*Connection) LogExec

func (c *Connection) LogExec(query string, args ...any) (sql.Result, error)

type WordInfo

type WordInfo struct {
	Id           int64
	Baby_Id      int64
	Word         string
	Number       int64
	Learned_Date string        // TODO type
	CreatedAt    string        `db:"created_at"` // TODO custom type
	ClientInfoId sql.NullInt64 `db:"client_info_id"`
}

Jump to

Keyboard shortcuts

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