db

package
v0.0.0-...-b893f33 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 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 {
	*sql.DB
}

Db is our database struct used for interacting with the database

func New

func New() (*Db, error)

New makes a new database using the connection string and returns it, otherwise returns the error

func (*Db) DestroyMessageByUUID

func (db *Db) DestroyMessageByUUID(uuid string) error

DestroyMessageByUUID rakes a uuid and attempts to destroy the associated record

func (*Db) DestroyStaleMessages

func (db *Db) DestroyStaleMessages() error

DestroyStaleMessages finds all messages older than 30 days and destroys them

func (*Db) GetMessageByUUID

func (db *Db) GetMessageByUUID(uuid string) (*Message, error)

GetMessageByUUID finds a message by it's UUID or returns an error

func (*Db) PostMessage

func (db *Db) PostMessage(msg Message) error

PostMessage takes a uuid and a message & inserts a new record into the db

type Message

type Message struct {
	ID            int    `json:"id"`
	UUID          string `json:"uuid"`
	Message       string `json:"message"`
	Email         string `json:"email"`
	ReferenceName string `json:"reference_name"`
	Password      string `json:"password"`
	CreatedAt     string `json:"created_at"`
}

Message represents a record from our "messages" column

Jump to

Keyboard shortcuts

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