You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
616 B
22 lines
616 B
package database
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.aiterp.net/rpdata/api/database/mongodb"
|
|
"git.aiterp.net/rpdata/api/internal/config"
|
|
"git.aiterp.net/rpdata/api/repositories"
|
|
)
|
|
|
|
// ErrDriverUnrecognized is returned if the driver is not recognized
|
|
var ErrDriverUnrecognized = errors.New("Driver not recognized, check your config or update rpdata")
|
|
|
|
// Init sets up the database.
|
|
func Init(config config.Database) (bundle *repositories.Bundle, closeFn func() error, err error) {
|
|
switch config.Driver {
|
|
case "mongo", "mgo", "mongodb":
|
|
return mongodb.Init(config)
|
|
default:
|
|
return nil, nil, ErrDriverUnrecognized
|
|
}
|
|
}
|