database

package
v0.0.0-...-c5b8c6d Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2014 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// An error to desginate that a row doesn't exist
	RowDoesNotExistError error = errors.New("Row does not exist.")
)

Functions

func ChangeAuth

func ChangeAuth(db *sqlx.DB, auth *Auth) error

Changing the current auth

func CreateDatabaseSchema

func CreateDatabaseSchema(db *sqlx.DB) error

Creating the database schema

func InsertCourse

func InsertCourse(db *sqlx.DB, course *Course) error

Inserting a course

func InsertPost

func InsertPost(db *sqlx.DB, post *Post) error

Inserting a post into the database (it should be noted that the ID of the post is ignored, and is left to the SQL database's PRIMARY KEY to auto-increment)

func InsertProject

func InsertProject(db *sqlx.DB, project *Project) error

Inserting a post

func MostRecent

func MostRecent(db *sqlx.DB) (int, error)

Getting the most recent post

func OpenDB

func OpenDB() (*sqlx.DB, error)

Opening a database connection

func QuickChangeAuth

func QuickChangeAuth(auth *Auth)

Quickly changing the current auth

func QuickInsertCourse

func QuickInsertCourse(course *Course)

Quickly inserting a course

func QuickInsertPost

func QuickInsertPost(post *Post)

Quickly inserting a post into the database

func QuickInsertProject

func QuickInsertProject(project *Project)

Quickly inserting a post

func QuickMostRecent

func QuickMostRecent() int

Quickly getting the most recent post

func QuickOpenDB

func QuickOpenDB() *sqlx.DB

Quickly opening a database connection

Types

type Auth

type Auth struct {
	Id       int    // The id for the auth
	Username string // The username for the auth
	Password string // The password for the auth
}

The auth type

func GetAuth

func GetAuth(db *sqlx.DB) (*Auth, error)

Getting the current auth

func MakeNewAuth

func MakeNewAuth(username string, password string) *Auth

Making a new auth

func QuickGetAuth

func QuickGetAuth() *Auth

Quickly getting the current auth

func (*Auth) Equal

func (auth1 *Auth) Equal(auth2 *Auth) bool

Checking if an auth equals another auth

func (*Auth) MakeCookie

func (auth *Auth) MakeCookie() *http.Cookie

Making a cookie from an auth

func (*Auth) SecureString

func (auth *Auth) SecureString() string

Converting the auth to a secure string

func (*Auth) String

func (auth *Auth) String() string

Converting the auth to a string

type Course

type Course struct {
	Title       string // The title of the course
	SerTitle    string // The serialized version of the course title
	Inst        string // The institution that offers the course
	Description string // The description of the course
	Comments    string // My personal comments on the course
}

func GetCourseBySerTitle

func GetCourseBySerTitle(db *sqlx.DB, sertitle string) (*Course, error)

Getting a course by its serialized title

func GetCourses

func GetCourses(db *sqlx.DB) ([]*Course, error)

Getting all of the courses

func MakeNewCourse

func MakeNewCourse(sertitle string, title string, inst string, description string, comments string) *Course

Making a new course object

func QuickGetCourseBySerTitle

func QuickGetCourseBySerTitle(sertitle string) *Course

Quickly getting a course by its serialized title

func QuickGetCourses

func QuickGetCourses() []*Course

Quickly getting all of the courses

type Post

type Post struct {
	Id      int       // The ID of the post
	Title   string    // The title of the post
	Author  string    // The author of the post
	Body    string    // The body of the post
	Written time.Time // The time the post was written
}

The post type

func GetPost

func GetPost(db *sqlx.DB, id int) (*Post, error)

Getting a post based on ID

func GetPosts

func GetPosts(db *sqlx.DB) ([]*Post, error)

Getting every post

func MakeNewPost

func MakeNewPost(title string, author string, body string) *Post

Making a new post, save id

func MakeNewPostRaw

func MakeNewPostRaw(id int, title string, author string, body string, written time.Time) *Post

Making a new post

func QuickGetPost

func QuickGetPost(id int) *Post

Quickly getting a post

func QuickGetPosts

func QuickGetPosts() []*Post

Quickly getting every post

func (*Post) Display

func (post *Post) Display() template.HTML

Displaying the post for listing on the /blob/ page

func (*Post) String

func (post *Post) String() string

Converting the post to a string

type Project

type Project struct {
	Title       string   // The title of the project
	Screenshots []string // URLs to screenshots of the project in action
	Language    string   // The language the project was written in
	ShortDesc   string   // A short version of the description
	Description string   // A description of the project
}

func GetProjectByTitle

func GetProjectByTitle(db *sqlx.DB, title string) (*Project, error)

Getting a project by its title

func GetProjects

func GetProjects(db *sqlx.DB) ([]*Project, error)

Getting all of the projects

func MakeProject

func MakeProject(title string, screenshots []string, language string, shortdesc string, description string) *Project

Making a new project object

func QuickGetProjectByTitle

func QuickGetProjectByTitle(title string) *Project

Quickly getting a project by its title

func QuickGetProjects

func QuickGetProjects() []*Project

Quickly getting all of the projects

type Schema

type Schema struct {
	Create string // The code to be executed when you want to create the database
	Drop   string // The code to be executed when you want to drop the database
}

The Schema struct

func LoadSchema

func LoadSchema(name string) (*Schema, error)

Loading a Schema from a file

func MustLoadSchema

func MustLoadSchema(name string) *Schema

Loading a Schema from a file and panicing on error

func (*Schema) String

func (this *Schema) String() string

Jump to

Keyboard shortcuts

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