Change config to use local/storage
This commit is contained in:
@@ -3,6 +3,7 @@ package driver
|
||||
import (
|
||||
"context"
|
||||
"local/dndex/config"
|
||||
"local/storage"
|
||||
"strings"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@@ -18,9 +19,12 @@ type Driver interface {
|
||||
|
||||
func New(path ...string) Driver {
|
||||
if len(path) == 0 {
|
||||
path = []string{config.New().DBURI}
|
||||
path = config.New().Driver
|
||||
}
|
||||
switch strings.ToLower(config.New().DriverType) {
|
||||
if t := storage.TypeFromString(path[0]); t >= 0 {
|
||||
return NewStorage(path...)
|
||||
}
|
||||
switch strings.ToLower(config.New().Driver[0]) {
|
||||
case "map":
|
||||
return NewMap()
|
||||
case "mongo":
|
||||
@@ -28,5 +32,5 @@ func New(path ...string) Driver {
|
||||
case "boltdb":
|
||||
return NewBoltDB(path[0])
|
||||
}
|
||||
panic("unknown driver type " + strings.ToLower(config.New().DriverType))
|
||||
panic("unknown driver type " + strings.ToLower(config.New().Driver[0]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user