database

package
v0.0.0-...-e48408c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configs

type Configs struct {
	Host     string
	Username string
	Password string
	Port     string
	Database string
	Driver   string
}

type Database

type Database struct {
	Schemaless bool
	// contains filtered or unexported fields
}

Database is a database connection

func Make

func Make(configs *Configs) (Database, error)

Make creates a new Database instance

func MakeSchemaless

func MakeSchemaless(configs *Configs) (Database, error)

MakeSchemaless makes a Database instance without a schema yet

func (*Database) CheckHasTable

func (d *Database) CheckHasTable(table string) (bool, error)

func (*Database) Close

func (database *Database) Close()

Close closes the database instance's connection

func (*Database) Exec

func (d *Database) Exec(query string, inserts []interface{}) (sql.Result, error)

Exec executes a query statement

func (*Database) MakeRecord

func (d *Database) MakeRecord(properties map[string]interface{}, table string) *Record

MakeRecord makes a record

func (*Database) Name

func (database *Database) Name() string

Name returns the name of the database instance

func (*Database) QueryRaw

func (d *Database) QueryRaw(query string, escaped []interface{}) ([]map[string]interface{}, error)

QueryRaw runs a raw select query against the database

func (*Database) Row

func (d *Database) Row(query string, id int64) (map[string]interface{}, error)

Row gets a row from the query

func (*Database) RowByStringField

func (d *Database) RowByStringField(query string, field string) (map[string]interface{}, error)

Row gets a row from the query

func (*Database) SetSchema

func (d *Database) SetSchema(schemaName string)

SetSchema sets a DB instance to having a schema

type Record

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

func (*Record) Create

func (r *Record) Create() (int64, error)

Create creates a new record

func (*Record) Update

func (r *Record) Update(id string) (int64, error)

Update updates an existing record

Jump to

Keyboard shortcuts

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