models

package
v0.0.0-...-75fe9c3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *sqlx.DB
)

Functions

func AddMemory

func AddMemory(memory *Memory) error

AddMemory inserts memory. The sequence ID generated by the database is set on memory.

func ApproveMemory

func ApproveMemory(memory Memory) error

ApproveMemory sets memory as approved.

func GetSlugCount

func GetSlugCount(slug string) (int, error)

GetSlugCount returns the number of times the given slug appears in the memory table.

func NamedInsert

func NamedInsert(query string, arg interface{}) (uint64, error)

NamedInsert executes the query insert statement and returns the generated sequence id.

func UpdateDetails

func UpdateDetails(memory Memory) error

UpdateDetails updates the details and update date for the given memory.

Types

type Memory

type Memory struct {
	ID           uint64    `db:"id" form:"id"`
	AddressText  string    `db:"address_text" form:"address_text"`
	Title        string    `db:"title" form:"title"`
	Slug         string    `db:"slug"`
	Details      string    `db:"details" form:"details"`
	Latitude     float64   `db:"latitude" form:"latitude"`
	Longitude    float64   `db:"longitude" form:"longitude"`
	Author       string    `db:"author" form:"author"`
	IsApproved   bool      `db:"is_approved"`
	ApprovalUUID string    `db:"approval_uuid"`
	EditUUID     string    `db:"edit_uuid"`
	InsertedAt   time.Time `db:"inserted_at"`
	UpdatedAt    time.Time `db:"updated_at"`
}

A Memory represents a single memory that is tied to a location.

func GetAllMemories

func GetAllMemories() ([]*Memory, error)

GetAllMemories returns all approved memories.

func GetMemory

func GetMemory(slug string) (Memory, error)

GetMemory returns an individual memory by slug. The memory will not be returned if it has not been approved.

func GetMemoryByApprovalUUID

func GetMemoryByApprovalUUID(uuid string) (Memory, error)

GetMemoryByApprovalUUID returns an indiviual memory by its approval UUID. The memory must not already be approved.

func GetMemoryByEditUUID

func GetMemoryByEditUUID(uuid string) (Memory, error)

GetMemoryByEditUUID returns an individual memory by its edit UUID. The memory will not be returned if it is not approved.

func GetRecentMemories

func GetRecentMemories() ([]*Memory, error)

GetRecentMemories returns the 5 most recent memories that are approved.

Jump to

Keyboard shortcuts

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