GraphQL API and utilities for the rpdata project
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

  1. package database
  2. import (
  3. "errors"
  4. "git.aiterp.net/rpdata/api/database/mongodb"
  5. "git.aiterp.net/rpdata/api/internal/config"
  6. "git.aiterp.net/rpdata/api/repositories"
  7. )
  8. // ErrDriverUnrecognized is returned if the driver is not recognized
  9. var ErrDriverUnrecognized = errors.New("Driver not recognized, check your config or update rpdata")
  10. // Init sets up the database.
  11. func Init(config config.Database) (bundle *repositories.Bundle, closeFn func() error, err error) {
  12. switch config.Driver {
  13. case "mongo", "mgo", "mongodb":
  14. return mongodb.Init(config)
  15. default:
  16. return nil, nil, ErrDriverUnrecognized
  17. }
  18. }