package driver

import (
	"context"
	"local/dndex/config"
	"strings"

	"go.mongodb.org/mongo-driver/bson"
)

type Driver interface {
	Find(context.Context, string, interface{}) (chan bson.Raw, error)
	Update(context.Context, string, interface{}, interface{}) error
	Insert(context.Context, string, interface{}) error
	Delete(context.Context, string, interface{}) error
}

func New() Driver {
	switch strings.ToLower(config.New().DriverType) {
	case "mongo":
		return NewMongo()
	case "boltdb":
		return NewBoltDB()
	}
	panic("unknown driver type " + strings.ToLower(config.New().DriverType))
}
