db

package
v0.0.0-...-41fd8b9 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: MIT Imports: 8 Imported by: 1

README

db Folder

DB stands for Database, these files are mostly used for connecting and querying the database. In this version its is very limited and only mysql is supported.

db/connection.go

The connection file contains all functions that are related to connecting with the database. This is also where you config the database for now.

db/querybuilder.go

The querybuilder file contains all functions that are related to building querys using functions. If you need to change or add SQL syntaxes this is where you would find it.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRows

func ReadRows(struc interface{}, rows *sql.Rows) []interface{}

ReadRows into array of interface type

Types

type Connection

type Connection struct {
	Host     string
	Port     string
	Database string
	Username string
	Password string
	// contains filtered or unexported fields
}

Connection is the connection to the database

func (*Connection) Close

func (dbc *Connection) Close() error

Close closes a connection to the database

func (*Connection) Default

func (dbc *Connection) Default()

Default sets the default options for the Connection

func (*Connection) Open

func (dbc *Connection) Open() error

Open opens a connection to the database

type QueryBuilder

type QueryBuilder struct {
	DBC Connection
	// contains filtered or unexported fields
}

QueryBuilder the builder for queries

func (*QueryBuilder) All

func (qb *QueryBuilder) All() (*sql.Rows, error)

All retrieves all data from selected table

func (*QueryBuilder) From

func (qb *QueryBuilder) From(table string) *QueryBuilder

From adds to the from part of the query

func (*QueryBuilder) GetWithID

func (qb *QueryBuilder) GetWithID(id int64, table string) (*sql.Rows, error)

GetWithID returns rows where id = given id from table

func (*QueryBuilder) Insert

func (qb *QueryBuilder) Insert(table string, values interface{}) (*sql.Rows, error)

Insert inserts values into table in database

func (*QueryBuilder) ResetQuery

func (qb *QueryBuilder) ResetQuery()

ResetQuery resets the query

func (*QueryBuilder) Select

func (qb *QueryBuilder) Select() *QueryBuilder

Select adds to the select part of the query

func (*QueryBuilder) Update

func (qb *QueryBuilder) Update(table string, values interface{}) (*sql.Rows, error)

Update updates values from table in database

func (*QueryBuilder) WhereRaw

func (qb *QueryBuilder) WhereRaw(raw string) *QueryBuilder

WhereRaw adds to the where part of the query

func (*QueryBuilder) WhereValue

func (qb *QueryBuilder) WhereValue(column string, value string) *QueryBuilder

WhereValue adds to the where part of the query by using column and value

func (*QueryBuilder) WhereValues

func (qb *QueryBuilder) WhereValues(values interface{}) *QueryBuilder

WhereValues adds to the where part of the query by using a interface

Jump to

Keyboard shortcuts

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