diff --git a/database/datasource/datasource_set.go b/database/datasource/datasource_set.go new file mode 100644 index 00000000..920892d6 --- /dev/null +++ b/database/datasource/datasource_set.go @@ -0,0 +1,22 @@ +package datasource + +import ( + "fmt" + + "github.com/grokify/mogo/type/maputil" +) + +type DataSourceSet struct { + Data map[string]DataSource +} + +func (dss DataSourceSet) GetDataSource(key string) (DataSource, error) { + if ds, ok := dss.Data[key]; ok { + return ds, nil + } + return DataSource{}, fmt.Errorf("key not found (%s)", key) +} + +func (dss DataSourceSet) Keys() []string { + return maputil.Keys(dss.Data) +}