Documentation ¶
Index ¶
Constants ¶
const ( // DatabaseNotSupportedErrMsg is the string used to indicate the provided DB is not supported DatabaseNotSupportedErrMsg = "Database not supported" // DBSQLite is a string that indicates sqlite is supported DBSQLite string = "sqlite" // DBPostgres is a string that indicates postgres is supported DBPostgres string = "postgres" // DBMongoDB is a string that indicates MongoDB is a supported database DBMongoDB string = "mongodb" // DBMySQL is a string that indicates mysql is supported DBMySQL string = "mysql" // DefaultSQLiteDBName will be used when user indicates they // want to create a SQLite db but do not provide a path/name DefaultSQLiteDBName string = "baseball_databank.sqlite3" )
Variables ¶
var ErrorDBNotSupported = errors.New(DatabaseNotSupportedErrMsg)
ErrorDBNotSupported is used to inform the caller that the database type the provided is not a supporeted database
Functions ¶
func CreateConnection ¶
func CreateConnection(opts Options) (sqlbuilder.Database, error)
CreateConnection is the public facing function that is responsible for providing a database connection to the outside world. It acts as a proxy fo the db package using the `dbtype` to determine which database connection to return. If somehow the dbtype is value we do not support a DB Not Supported error will be returned
func CreateNoSQLConnection ¶
CreateNoSQLConnection is the public facing function that is responsible for providing a nosql database connection to the outside world. It acts as a proxy fo the db package using the `dbtype` to determine which database connection to return. If somehow the dbtype is value we do not support a DB Not Supported error will be returned
func IsSupportedDB ¶
IsSupportedDB checks to see if the database name given is one of the dbs supported by Baseball Databank Tools
Types ¶
type CreateDBConnFunc ¶
type CreateDBConnFunc func(Options) (sqlbuilder.Database, error)
CreateDBConnFunc is the type of function that all supported databases must support
type InsertFunc ¶
InsertFunc Inserts the data into the table specified in the first parameter
type NoSQLRepo ¶
type NoSQLRepo struct {
// contains filtered or unexported fields
}
NoSQLRepo handles interaction between the database and the caller
type Options ¶
type Options struct { Host string Name string Pass string Path string Port int Type string User string Verbose bool }
Options are used to connect to the database file or server depending on the type of database being used
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is the struct that manages the inserting of data and closing of db connections across the supported databases
type Repository ¶
type Repository interface { CloseConn() error Insert(string, interface{}) error Truncate(string) error }
Repository is the interface used by all of the database objects
func CreateNoSQLRepo ¶
func CreateNoSQLRepo(sd db.Database) Repository
CreateNoSQLRepo creates a Repository object that is connected to the database.
func CreateRepo ¶
func CreateRepo(sd sqlbuilder.Database) Repository
CreateRepo creates a Repositoryobject that is connected to the database.