Initial commit

This commit is contained in:
2022-08-11 17:21:32 +02:00
commit f6aa45944d
19 changed files with 2605 additions and 0 deletions

30
storage/storage.go Normal file
View File

@@ -0,0 +1,30 @@
package storage
import (
"fmt"
"github.com/spf13/viper"
)
type Storage interface {
CreateGroup(Group) error
GetGroup(string) (*Group, error)
GetGroups([]string) ([]Group, error)
GetGroupsByIds([]string) ([]Group, error)
UpdateGroup(Group) 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)
}
}