Compatible with both bolt and mongo, wewt

This commit is contained in:
Bel LaPointe
2020-07-23 20:01:09 -06:00
parent 99885da94f
commit 4416a7e4b3
3 changed files with 57 additions and 2 deletions

View File

@@ -3,9 +3,11 @@ package storage
import (
"context"
"fmt"
"local/dndex/config"
"local/dndex/storage/driver"
"local/dndex/storage/entity"
"local/dndex/storage/operator"
"strings"
"go.mongodb.org/mongo-driver/bson"
)
@@ -15,9 +17,15 @@ type Graph struct {
}
func NewGraph() Graph {
mongo := driver.NewMongo()
var d driver.Driver
switch strings.ToLower(config.New().DriverType) {
case "mongo":
d = driver.NewMongo()
case "boltdb":
d = driver.NewBoltDB()
}
return Graph{
driver: mongo,
driver: d,
}
}