basemysql

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: MIT Imports: 5 Imported by: 0

README

base-mysql

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fields

func Fields(values interface{}) []string

Fields retorna []string campos da struct com tag field

Types

type Db

type Db struct {

	//Conn deve substituir con em futura versão major
	Conn                                 *sql.DB //conexão banco
	User, Password, Host, Port, Database string
	// contains filtered or unexported fields
}

Db mantem conexao com banco MySQL Provê métodos para update/insert/select

func (*Db) Close

func (db *Db) Close()

Close encerra conexao com banco MySQL

func (*Db) Connect

func (db *Db) Connect() error

Connect mantém conexao ativa com banco

func (*Db) FetchLines

func (db *Db) FetchLines(table string, selectFields []string, where string, valuesWhere []interface{}) (result *[]interface{}, er error)

FetchLines retorna select de campos fornecidos em slice de strings

func (*Db) Insert

func (db *Db) Insert(table string, columns []string, columnsValue []interface{}) (int64, error)

Insert - Adiciona nova linha na tabela informada, deve-se informar todas as colunas na mesma ordem dos campos na declaração da tabela.

func (*Db) Update

func (db *Db) Update(table string, id uint, columns map[string]string) (sql.Result, error)

Update realiza update de linhas selecionadas por where

Jump to

Keyboard shortcuts

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