mcdb

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 12 Imported by: 0

README

mcdb | github.com/abbeymart/mcdbgo

  • Db Connection module/packages for PostgresSQL, SQLite3 and MongoDB
  • PostgresSQL: used go-database/sql & github.com/lib/pq, and pgx/pgxpool package
  • SQLite3: used go-database/sql & github.com/mattn/go-sqlite3
  • MongoDB: used go.mongodb.org/mongo-driver/mongo
  • See test files for test cases / scenarios

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db struct {
	DbConn *pgx.Conn
}

type DbConfig

type DbConfig struct {
	DbType       string           `json:"dbType"`
	Host         string           `json:"host"`
	Username     string           `json:"username"`
	Password     string           `json:"password"`
	DbName       string           `json:"dbName"`
	Filename     string           `json:"filename"`
	Location     string           `json:"location"`
	Port         uint32           `json:"port"`
	PoolSize     uint             `json:"poolSize"`
	Url          string           `json:"url"`
	SecureOption DbSecureType     `json:"secureOption"`
	Options      DbConnectOptions `json:"options"`
}

func (DbConfig) CloseDb

func (dbConfig DbConfig) CloseDb()

func (DbConfig) ClosePgxDb

func (dbConfig DbConfig) ClosePgxDb()

func (DbConfig) ClosePgxDbPool

func (dbConfig DbConfig) ClosePgxDbPool()

func (DbConfig) OpenDb

func (dbConfig DbConfig) OpenDb() (*sql.DB, error)

func (DbConfig) OpenPgxDb

func (dbConfig DbConfig) OpenPgxDb() (*Db, error)

func (DbConfig) OpenPgxDbPool

func (dbConfig DbConfig) OpenPgxDbPool() (*DbPool, error)

type DbConfigType

type DbConfigType struct {
	Host         string       `json:"host"`
	Username     string       `json:"username"`
	Password     string       `json:"password"`
	DbName       string       `json:"dbName"`
	Filename     string       `json:"filename"`
	Location     string       `json:"location"`
	Port         uint32       `json:"port"`
	DbType       string       `json:"dbType"`
	PoolSize     uint         `json:"poolSize"`
	Url          string       `json:"url"`
	SecureOption DbSecureType `json:"secureOption"`
}

type DbConnectOptions

type DbConnectOptions map[string]interface{}

type DbConnectionType

type DbConnectionType *sql.DB

type DbPool

type DbPool struct {
	DbConn *pgxpool.Pool
}

type DbSecureType

type DbSecureType struct {
	SecureAccess bool   `json:"secureAccess"`
	SecureCert   string `json:"secureCert"`
	SecureKey    string `json:"secureKey"`
	SslMode      string `json:"sslMode"`
}

type MongoDbConfig

type MongoDbConfig struct {
	DbType   string
	Host     string
	Username string
	Password string
	DbName   string
	Filename string
	Location string
	Port     uint32
	PoolSize uint
	Url      string
	Options  MongoDbConnectOptions
}

func (MongoDbConfig) CloseMongoDb

func (dbConfig MongoDbConfig) CloseMongoDb()

func (MongoDbConfig) OpenMongoDb

func (dbConfig MongoDbConfig) OpenMongoDb() (*mongo.Client, error)

type MongoDbConfigType

type MongoDbConfigType struct {
	Host         string
	Username     string
	Password     string
	DbName       string
	Filename     string
	Location     string
	Port         uint32
	DbType       string
	PoolSize     uint
	SecureOption MongoDbSecureType
	Uri          string
}

type MongoDbConnectOptions

type MongoDbConnectOptions map[string]interface{}

type MongoDbConnectionType

type MongoDbConnectionType *mongo.Client

type MongoDbSecureType

type MongoDbSecureType struct {
	SecureAccess bool
	SecureCert   string
	SecureKey    string
}

Jump to

Keyboard shortcuts

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