db

package
v0.0.0-...-b6cfeee Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB represents the database connection.

func ConnectToDB

func ConnectToDB() (*DB, error)

NewDB creates a new DB instance with the provided MySQL connection details.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) Create

func (db *DB) Create(query string, args ...interface{}) (int64, error)

Create executes an insert query and returns the ID of the newly inserted row.

func (*DB) Delete

func (db *DB) Delete(query string, args ...interface{}) (int64, error)

Delete executes a delete query and returns the number of affected rows.

func (*DB) Read

func (db *DB) Read(query string, args ...interface{}) (*sql.Row, error)

Read executes a select query and returns a row result.

func (*DB) ReadAll

func (db *DB) ReadAll(query string, args ...interface{}) (*sql.Rows, error)

ReadAll executes a select query and returns a result set.

func (*DB) Update

func (db *DB) Update(query string, args ...interface{}) (int64, error)

Update executes an update query and returns the number of affected rows.

Jump to

Keyboard shortcuts

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