lib

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSS_PARAM_REQUIRED      = "Param is required (%s)"
	MSG_DRIVER_NOT_FOUND    = "Driver not found"
	ERR_COMMAN_MARCHALING   = "Command error marshaling data to JSON: %v"
	ERR_MASTER_DB_NOT_FOUND = "Master db not found"
)

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(db *linq.DB, name, password string) error

ChangePassword change the password of the user

func ConnStr

func ConnStr(params *linq.Connection) (string, error)

* * ConnStr return a connection string * @param params *linq.Connection * @return string * @return error *

func Connect

func Connect(connStr string) (*sql.DB, error)

* * Connect return a connection to a database * @param connStr string * @return *sql.DB * @return error *

func CreateColumn

func CreateColumn(db *linq.DB, schema, table, name, kind, _default string) error

CreateColumn create a column if not exists in the table

func CreateDatabase

func CreateDatabase(db *linq.DB, name string) error

CreateDatabase create a database if not exists

func CreateIndex

func CreateIndex(db *linq.DB, schema, table, field string) error

CreateIndex create a index if not exists in the table

func CreateSchema

func CreateSchema(db *linq.DB, name string) error

CreateSchema create a schema if not exists

func CreateSequence

func CreateSequence(db *linq.DB, schema, tag string) error

CreateSequence create a sequence if not exists

func CreateTrigger

func CreateTrigger(db *linq.DB, schema, table, name, when, event, function string) error

CreateTrigger create a trigger if not exists in the table

func CreateUser

func CreateUser(db *linq.DB, name, password string) error

CreateUser create a user if not exists

func DropColumn

func DropColumn(db *linq.DB, schema, table, name string) error

DropColumn drop a column if exists in the table

func DropDatabase

func DropDatabase(db *linq.DB, name string) error

DropDatabase drop a database if exists

func DropIndex

func DropIndex(db *linq.DB, schema, table, field string) error

DropIndex drop a index if exists in the table

func DropSchema

func DropSchema(db *linq.DB, name string) error

DropSchema drop a schema if exists

func DropSerie

func DropSerie(db *linq.DB, schema, name string) error

DropSerie drop a serie if exists

func DropTable

func DropTable(db *linq.DB, schema, name string) error

DropTable drop a table if exists

func DropTrigger

func DropTrigger(db *linq.DB, schema, table, name string) error

DropTrigger drop a trigger if exists in the table

func DropUser

func DropUser(db *linq.DB, name string) error

DropUser drop a user if exists

func ExistColum

func ExistColum(db *linq.DB, schema, table, name string) (bool, error)

ExistColum check if the column exists in the table

func ExistDatabase

func ExistDatabase(db *linq.DB, name string) (bool, error)

* * ExistDatabase check if the database exists * @param db *linq.DB * @param name string * @return bool, error *

func ExistIndex

func ExistIndex(db *linq.DB, schema, table, field string) (bool, error)

ExistIndex check if the index exists in the table

func ExistSchema

func ExistSchema(db *linq.DB, name string) (bool, error)

ExistSchema check if the schema exists

func ExistSerie

func ExistSerie(db *linq.DB, schema, name string) (bool, error)

ExistSerie check if the serie exists

func ExistTable

func ExistTable(db *linq.DB, schema, name string) (bool, error)

ExistTable check if the table exists

func ExistTrigger

func ExistTrigger(db *linq.DB, schema, table, name string) (bool, error)

ExistTrigger check if the trigger exists in the table

func ExistUser

func ExistUser(db *linq.DB, name string) (bool, error)

ExistUser check if the user exists

func NewDriver

func NewDriver() linq.Driver

Types

type Postgres

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

Postgres struct to define a postgres database

func (*Postgres) Connect

func (d *Postgres) Connect(params *linq.Connection) (*linq.DB, error)

* * Connect to the database * @param params et.Json * @return *linq.DB * @return error *

func (*Postgres) CurrentSerie

func (d *Postgres) CurrentSerie(tag string) (int, error)

* * CurrentSerie return the current value of a serie * @param tag string * @return int *

func (*Postgres) CurrentSql

func (d *Postgres) CurrentSql(l *linq.Linq) string

* * CurrentSql return the sql to select * @param l *linq.Linq * @return string *

func (*Postgres) DCL

func (d *Postgres) DCL(command string, params et.Json) (et.Item, error)

* * DCL execute a Data Control Language command * @param command string * @param params et.Json * @return error *

func (*Postgres) DefineSql

func (d *Postgres) DefineSql(m *linq.Model) string

* * DefineSql return DDL sql to define a model * @param m *linq.Model * @return string *

func (*Postgres) DeleteSerie

func (d *Postgres) DeleteSerie(tag string) error

* * DeleteSerie delete a serie * @param tag string * @return int *

func (*Postgres) DeleteSql

func (d *Postgres) DeleteSql(l *linq.Linq) string

* * DeleteSql return the sql to delete * @param l *linq.Linq * @return string *

func (*Postgres) GetCommand

func (d *Postgres) GetCommand(id string) (et.Item, error)

* * GetCommand * @params id string * @return et.Item * @return error *

func (*Postgres) GetMigrateId

func (d *Postgres) GetMigrateId(old_id, tag string) (string, error)

* * GetMigrateId get a migrate id * @param old_id string * @param tag string * @return string * @return error *

func (*Postgres) InsertSql

func (d *Postgres) InsertSql(l *linq.Linq) string

* * InsertSql return the sql to insert * @param l *linq.Linq * @return string *

func (*Postgres) LoadMode

func (d *Postgres) LoadMode() error

* * LoadMode return if the core is used * @return bool *

func (*Postgres) Master

func (d *Postgres) Master(params *linq.Connection) (*linq.DB, error)

* * Master execute a query * @param db *linq.DB * @param commandListener linq.HandlerListend * @return error *

func (*Postgres) Mode

func (d *Postgres) Mode() linq.ModeDatabase

* * Mode return the mode of the database * @return linq.ModeDatabase *

func (*Postgres) ModelExist

func (d *Postgres) ModelExist(schema, name string) (bool, error)

* * ModelExist get a model from the database * @param schema string * @param name string * @return et.Json *

func (*Postgres) MutationSql

func (d *Postgres) MutationSql(m *linq.Model) string

* * MutationSql return DDL mutation the sql to mutate * @param l *linq.Linq * @return string *

func (*Postgres) NextCode

func (d *Postgres) NextCode(tag, format string) (string, error)

* * NextCode return the next code of a serie * @param tag string * @param format string, example 'A000000-2024' A%05d-2024 * @return string * @return error *

func (*Postgres) NextSerie

func (d *Postgres) NextSerie(tag string) (int, error)

* * NextSerie return the next value of a serie * @param tag string * @return int * @return error *

func (*Postgres) SelectSql

func (d *Postgres) SelectSql(l *linq.Linq) string

* * SelectSql return the sql to select * @param l *linq.Linq * @return string *

func (*Postgres) SetCommand

func (d *Postgres) SetCommand(query string) error

* * SetCommand * @params query string *

func (*Postgres) SetListen

func (p *Postgres) SetListen(channels []string, listen linq.HandlerListend)

* * SetListen set the channels to listen * @param channels []string * @param listen linq.HandlerListend *

func (*Postgres) SetMutex

func (d *Postgres) SetMutex(id, query string, index int64) error

* * SetMutex * @params id string * @params query string * @params index int64 * @return error *

func (*Postgres) SetSerie

func (d *Postgres) SetSerie(tag string, val int) error

* * SetSerie set the value of a serie * @param tag string * @param val int * @return error *

func (*Postgres) SyncCommand

func (d *Postgres) SyncCommand() error

* * SyncCommand * @return error *

func (*Postgres) Type

func (d *Postgres) Type() string

* * Type return the type of the database * @return string *

func (*Postgres) UpSertMigrateId

func (d *Postgres) UpSertMigrateId(old_id, _id, tag string) error

* * UpSertMigrateId upsert a migrate id * @param old_id string * @param _id string * @param tag string * @return error *

func (*Postgres) UpdateSql

func (d *Postgres) UpdateSql(l *linq.Linq) string

* * UpdateSql return the sql to update * @param l *linq.Linq * @return string *

Jump to

Keyboard shortcuts

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