package driver import ( "context" "local/dndex/config" "strings" "go.mongodb.org/mongo-driver/bson" ) type Driver interface { Count(context.Context, string, interface{}) (int, error) 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(path ...string) Driver { if len(path) == 0 { path = []string{config.New().DBURI} } switch strings.ToLower(config.New().DriverType) { case "map": return NewMap() case "mongo": return NewMongo(path[0]) case "boltdb": return NewBoltDB(path[0]) } panic("unknown driver type " + strings.ToLower(config.New().DriverType)) }