24 lines
383 B
Go
24 lines
383 B
Go
|
package db
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"th7/ports"
|
||
|
)
|
||
|
|
||
|
func NewAdapter(db map[string]interface{}) (ports.DBPort, error) {
|
||
|
|
||
|
// if no "type" is given, use dummy
|
||
|
if _, ok := db["type"]; !ok {
|
||
|
return NewDummyAdapter()
|
||
|
}
|
||
|
|
||
|
db_type := fmt.Sprint(db["type"])
|
||
|
switch db_type {
|
||
|
case "sqlite3":
|
||
|
return NewSQLite3Adapter(db)
|
||
|
}
|
||
|
|
||
|
return &DummyAdapter{}, errors.New("unknown db type")
|
||
|
}
|