Version: v0.0.0-...-276be26 Latest Latest

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 1 Imported by: 1




This section is empty.


View Source
var (
	DefaultDBConfig = Config{
			CurrentBackend: "couchdb",
			CurrentEnv:     "dev",
			Backends: map[string]WhatEnv{
				"couchdb": {

					"dev": &ConfigItem{
						Hosts: []string{
						Username: "admin",
						Password: "safe,2017",
						Database: "test",
			Debug: true,


This section is empty.


type Config

type Config struct {
	DB WhatDB `json:"db" yaml:"db"`
	// contains filtered or unexported fields

func (*Config) GetBackend

func (s *Config) GetBackend() DbBackend

func (*Config) IsValid

func (s *Config) IsValid() bool

func (*Config) SetBackend

func (s *Config) SetBackend(b DbBackend)

type ConfigItem

type ConfigItem struct {
	Hosts                    []string `json:"hosts" yaml:"hosts"`
	Username                 string   `json:"username,omitempty" yaml:"username,omitempty"`
	Password                 string   `json:"password,omitempty" yaml:"password,omitempty"`
	Database                 string   `json:"database,omitempty" yaml:"database,omitempty"`
	ReplicaSet               string   `json:"replicaSet,omitempty" yaml:"replicaSet,omitempty"`
	DisableInitialHostLookup bool     `json:"disableInitialHostLookup,omitempty" yaml:"disableInitialHostLookup,omitempty"`
	Description              string   `json:"desc,omitempty" yaml:"desc,omitempty"`
	// contains filtered or unexported fields

func (*ConfigItem) GetEcho

func (s *ConfigItem) GetEcho() *echo.Echo

func (*ConfigItem) SetEcho

func (s *ConfigItem) SetEcho(e *echo.Echo)

type DbBackend

type DbBackend interface {

	// must use the defer pattern:
	//   defer session.Close()
	Open() (session DbSession)
	// no use

type DbCRUD

type DbCRUD interface {
	Insert() (rows int, err error)
	Update() (rows int, err error)
	// Get a single record by PK
	Get() (err error)
	Delete() bool
	Exists() bool

	// if condition checked then skip (or update the Model)
	// if unchecked (not exists), insert as a new record.
	InsertOrUpdate(conditions ...string) bool

	// Get a single record by conditions and params
	GetOne(conditions string, params ...interface{}) bool
	Query(results *[]interface{}, conditions string, params ...interface{}) *[]interface{}

	UpdateWith(conditionFields ...string) bool
	ExistsWith(conditionFields ...string) bool

	ExistsBy(conditions string, params ...interface{}) bool
	DeleteBy(conditions string, params ...interface{}) bool

type DbModel

type DbModel interface {

type DbSession

type DbSession interface {
	GetCRUD(model DbModel, tableName string, pkColumns ...string) (crud DbCRUD)

type WhatDB

type WhatDB struct {
	CurrentBackend string             `json:"backend" yaml:"backend"`
	CurrentEnv     string             `json:"env" yaml:"env"`
	Backends       map[string]WhatEnv `json:"backends" yaml:"backends"`
	Debug          bool               `json:"debug" yaml:"debug"`

type WhatEnv

type WhatEnv map[string]*ConfigItem

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL