initial commit
This commit is contained in:
27
storage/storage.go
Normal file
27
storage/storage.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
CreateRegularRoutes([]*geojson.FeatureCollection) error
|
||||
GetUserRegularRoutes(userid string) ([]*geojson.FeatureCollection, error)
|
||||
}
|
||||
|
||||
func NewStorage(cfg *viper.Viper) (Storage, error) {
|
||||
var (
|
||||
storage_type = cfg.GetString("storage.db.type")
|
||||
)
|
||||
|
||||
switch storage_type {
|
||||
case "mongodb":
|
||||
s, err := NewMongoDBStorage(cfg)
|
||||
return s, err
|
||||
default:
|
||||
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user