database

package
v0.0.0-...-ec4765f Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 18 Imported by: 0

README

DATABASE

Database folder containing database connection function and method to our postgresql server. To connect with the database, we are using pgx to get best performance. The db.go file contain database pool connection preparation and validation for the established pool connection.

File Structure
|-- database
|-- |-- sql
|-- |-- |-- user.sql
|-- |-- db.go
|-- |-- README.md

Documentation

Overview

package database db.go - contain database pool connection preparation and validation for the established pool connection

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBPool

func NewDBPool(dsn config.Database) (*pgxpool.Pool, func(), error)

NewDBPool is to create new pool connection to database

Types

type IDatabase

type IDatabase interface {
	// Exec acquires a connection from the Pool and executes the given SQL.
	// SQL can be either a prepared statement name or an SQL string.
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)

	// QueryRow acquires a connection and executes a query that is expected
	// to return at most one row (pgx.Row)
	QueryRow(context.Context, string, ...interface{}) pgx.Row

	// Query acquires a connection and executes a query that returns pgx.Rows.
	// Arguments should be referenced positionally from the SQL string as $1, $2, etc.
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)

	// Close closes all connections in the pool and rejects future Acquire calls. Blocks until all connections are returned
	// to pool and closed.
	Close()
}

IDatabase is interface to pgxpool method

Jump to

Keyboard shortcuts

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