library

package
v0.0.0-...-3c3b521 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("model not found")

ErrNotFound is the error returned when a model cannot be found.

Functions

func NewID

func NewID() string

NewID creates model IDs, in a real app this would be done by the DB or would use some form of GUID.

Types

type Address

type Address struct {
	// Number is the street number.
	Number int
	// Street is the street name.
	Street string
	// City is the city name.
	City string
	// State is the US state 2 letter code.
	State string
	// Zip is the US Zip code.
	Zip int
}

Address is a street address.

type CourseModel

type CourseModel struct {
	// ID is the course identifier.
	ID string
	// Name is the unique course name.
	Name string
	// Description is the course description.
	Description string
	// StatTime is the data and time the course starts.
	StartTime time.Time
	// EndTime is the date and time the course ends.
	EndTime time.Time
	// Location is the place the course is being held at.
	Location string
}

CourseModel is the database model used to persist courses.

type MemDB

type MemDB struct {
	*memdb.MemDB
}

MemDB is an in-memory database.

func NewDB

func NewDB() *MemDB

NewDB returns a new in-memory database pre-initialized with seed data.

func NewEmptyDB

func NewEmptyDB() *MemDB

NewEmptyDB returns an empty database, mainly intended for tests.

func (*MemDB) Delete

func (db *MemDB) Delete(table string, fieldName string, fieldVal interface{}) error

Delete deletes the entry from table where the field fieldName has the value fieldVal.

func (*MemDB) Get

func (db *MemDB) Get(table string, fieldName string, fieldVal interface{}) (interface{}, error)

Get retrieves the entry from table where the field fieldName has the value fieldVal.

func (*MemDB) Insert

func (db *MemDB) Insert(table string, data interface{}) error

Insert inserts the data in the given table.

func (*MemDB) List

func (db *MemDB) List(table string, fieldName string, fieldVal interface{}) ([]interface{}, error)

List retrieves all entries from the table where the field fieldName has the value fieldVal. If fieldVal is nil then List returns all the entries.

func (*MemDB) Wipe

func (db *MemDB) Wipe()

Wipe deletes the entire DB content, mainly intended for tests.

type RegistrationModel

type RegistrationModel struct {
	// ID is the registration identifier.
	ID string
	// CourseID is the course identifier.
	CourseID string
	// FirstName is the attendee first name.
	FirstName string
	// LastName is the attendee last name.
	LastName string
	// Address is the attendee street address.
	Address *Address
}

RegistrationModel is the database model used to persist registrations.

type UserModel

type UserModel struct {
	// Email is the user email.
	Email string
	// HashedPassword is the user password hashed with bcrypt.
	HashedPassword string
}

UserModel is the database model used to persist users.

Jump to

Keyboard shortcuts

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