diff --git a/sea.go b/sea.go index 3c7b8e9..72604c5 100644 --- a/sea.go +++ b/sea.go @@ -21,25 +21,30 @@ func Connect() (*Sea, error) { return &sea, nil } +func openDB() (*sqlx.DB, error) { + db, err := sqlx.Open("mysql", "itman:X753951x@(xigmanas:3306)/sea") + if err != nil { + return nil, err + } + return db, nil +} + // ============= ALBUM ============ + type Album struct { Seria string Cnt int Hash string } -// func getAlbums(db *sqlx.DB) []Album { -// cmd := "call getAlbums()" -// var albums []Album -// err := db.Select(&albums, cmd) -// return albums -// } - -func openDB() (*sqlx.DB, error) { - db, err := sqlx.Open("mysql", "itman:X753951x@(xigmanas:3306)/sea") +func (s *Sea) Albums(db *sqlx.DB) ([]Album, error) { + cmd := "call getAlbums()" + var albums []Album + err := db.Select(&albums, cmd) if err != nil { return nil, err } - return db, nil + return albums, nil } +