refactors data access layer to use pop ORM for eager loading, adds book titles rented to renters in response body
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/gobuffalo/pop"
|
||||
)
|
||||
|
||||
// store holds a connection to the application database.
|
||||
type store struct {
|
||||
*sqlx.DB
|
||||
*pop.Connection
|
||||
}
|
||||
|
||||
// NewStore creates a new connection to the database and returns a store containing the connection.
|
||||
func NewStore(dsn string) (s *store, err error) {
|
||||
db, err := sqlx.Open("mysql", dsn)
|
||||
db, err := pop.Connect("development")
|
||||
if err != nil {
|
||||
return s, err
|
||||
return &store{}, err
|
||||
}
|
||||
|
||||
return &store{db}, nil
|
||||
|
||||
Reference in New Issue
Block a user