models

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 7 Imported by: 0

README

ashilda-common

Documentation

Index

Constants

View Source
const (
	Select           string = "SELECT"
	InsertInto       string = "INSERT INTO"
	Update           string = "UPDATE"
	Set              string = "SET"
	Delete           string = "DELETE"
	Values           string = "VALUES"
	From             string = "FROM"
	Where            string = "WHERE"
	And              string = "AND"
	Space            string = " "
	LeftParentheses  string = "("
	RightParentheses string = ")"
	SemiColon        string = ";"
	LessThan         string = "<"
	GreaterThan      string = ">"
	Equals           string = "="
	Comma            string = ","
	Apostrophe       string = "'"
)

Constants to represent the syntax of SQL statements

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Host       string
	Port       string
	Name       string
	Username   string
	Password   string
	Connection *sql.DB
}

Database type holds the details for the connection and the connection itself

func NewDatabase

func NewDatabase() *Database

NewDatabase method to construct the database type

func (*Database) Connect

func (db *Database) Connect()

Connect method attempts to establish a connection to the database

func (*Database) ExecuteDelete added in v0.6.0

func (db *Database) ExecuteDelete(dd *DatabaseDelete) error

ExecuteDelete method executes an SQL delete statement

func (*Database) ExecuteInsert added in v0.6.0

func (db *Database) ExecuteInsert(di *DatabaseInsert) error

ExecuteInsert method executes an SQL insert statement

func (*Database) ExecuteSelect added in v0.6.0

func (db *Database) ExecuteSelect(ds *DatabaseSelect) (*sql.Rows, error)

ExecuteSelect method executes a select statement and returns the rows

func (*Database) ExecuteUpdate added in v0.6.0

func (db *Database) ExecuteUpdate(du *DatabaseUpdate) error

ExecuteUpdate method executes an SQL update statement

type DatabaseDelete added in v0.6.0

type DatabaseDelete struct {
	// contains filtered or unexported fields
}

DatabaseDelete type represents an SQL delete statement

func NewDatabaseDelete added in v0.6.0

func NewDatabaseDelete(t string) *DatabaseDelete

NewDatabaseDelete method to construct the DatabaseDelete type

func (*DatabaseDelete) AddCondition added in v0.6.0

func (dd *DatabaseDelete) AddCondition(c string, o string, v string)

AddCondition method to add a single condition to the SQL query

func (*DatabaseDelete) Generate added in v0.6.0

func (dd *DatabaseDelete) Generate() string

Generate method compiles the query and returns the generated string

type DatabaseInsert added in v0.6.0

type DatabaseInsert struct {
	// contains filtered or unexported fields
}

DatabaseInsert type represents an SQL insert statement

func NewDatabaseInsert added in v0.6.0

func NewDatabaseInsert(t string) *DatabaseInsert

NewDatabaseInsert method to construct the DatabaseInsert type

func (*DatabaseInsert) AddEntry added in v0.6.0

func (di *DatabaseInsert) AddEntry(c string, v string)

AddEntry method adds a single value to insert into the table

func (*DatabaseInsert) Generate added in v0.6.0

func (di *DatabaseInsert) Generate() string

Generate method compiles the query and returns the generated string

type DatabaseSelect added in v0.6.0

type DatabaseSelect struct {
	// contains filtered or unexported fields
}

DatabaseSelect type represents an SQL select statement

func NewDatabaseSelect added in v0.6.0

func NewDatabaseSelect(t string) *DatabaseSelect

NewDatabaseSelect method to construct the DatabaseSelect type

func (*DatabaseSelect) AddColumn added in v0.6.0

func (ds *DatabaseSelect) AddColumn(c string)

AddColumn method adds a single column to return from SQL statement

func (*DatabaseSelect) AddCondition added in v0.6.0

func (ds *DatabaseSelect) AddCondition(c string, o string, v string)

AddCondition method to add a single condition to the SQL query

func (*DatabaseSelect) Generate added in v0.6.0

func (ds *DatabaseSelect) Generate() string

Generate method compiles the query and returns the generated string

type DatabaseUpdate added in v0.6.0

type DatabaseUpdate struct {
	// contains filtered or unexported fields
}

DatabaseUpdate type represents an SQL update statement

func NewDatabaseUpdate added in v0.6.0

func NewDatabaseUpdate(t string) *DatabaseUpdate

NewDatabaseUpdate method to construct the DatabaseUpdate type

func (*DatabaseUpdate) AddCondition added in v0.6.0

func (du *DatabaseUpdate) AddCondition(c string, o string, v string)

AddCondition method to add a single condition to the SQL query

func (*DatabaseUpdate) AddStatement added in v0.6.0

func (du *DatabaseUpdate) AddStatement(c string, v string)

AddStatement method to add a single update statement to SQL query

func (*DatabaseUpdate) Generate added in v0.6.0

func (du *DatabaseUpdate) Generate() string

Generate method compiles the query and returns the generated string

type DeleteCondition added in v0.6.0

type DeleteCondition struct {
	// contains filtered or unexported fields
}

DeleteCondition type represents a condition within an SQL statement

type Router added in v0.11.0

type Router struct {
	BasePath string
	Database Database
	Mux      *mux.Router
}

Router type for holding mux router and database connection used in handlers

func NewRouter added in v0.11.0

func NewRouter(bp string) *Router

NewRouter method to construct Router type

type SelectCondition added in v0.6.0

type SelectCondition struct {
	// contains filtered or unexported fields
}

SelectCondition type represents a single SQL condition statement

type UpdateCondition added in v0.6.0

type UpdateCondition struct {
	// contains filtered or unexported fields
}

UpdateCondition type represents a condition within an SQL statement

type UpdateStatement added in v0.6.0

type UpdateStatement struct {
	// contains filtered or unexported fields
}

UpdateStatement type represents a single update within an SQL statement

Directories

Path Synopsis
models module

Jump to

Keyboard shortcuts

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