silvermobi/storage/storage.go

26 lines
642 B
Go

package storage
import (
"fmt"
"github.com/spf13/viper"
)
type Storage interface {
CreateFirebaseToken(user_id string, fcm_token string, device_platform string) (err error)
UpdateFirebaseToken(user_id string, fcm_token string, device_platform string) error
GetFirebaseToken(user_id string) (fcm string, device_platform string, err error)
}
func NewStorage(cfg *viper.Viper) (Storage, error) {
var (
storage_type = cfg.GetString("storage.db.type")
)
switch storage_type {
case "psql":
s, err := NewPostgresqlStorage(cfg)
return s, err
default:
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
}
}