package models

import (
	"database/sql"
	"errors"
	"os"

	_ "github.com/lib/pq"
)

func InitDatabase() (*sql.DB, error) {
	connection := os.Getenv("DB_CONNECTION")

	if len(connection) == 0 {
		return nil, errors.New("DB_CONNECTION env was not found.")
	}

	return sql.Open("postgres", connection)
}
