Elizabeth Hunt
f163a24279
All checks were successful
continuous-integration/drone/push Build is passing
34 lines
638 B
Go
34 lines
638 B
Go
package database
|
|
|
|
import (
|
|
"database/sql"
|
|
"log"
|
|
)
|
|
|
|
type Fren struct {
|
|
Id string
|
|
Name string
|
|
}
|
|
|
|
func FindFren(dbConn *sql.DB, id string) (*Fren, error) {
|
|
row := dbConn.QueryRow(`SELECT id, name FROM frens WHERE id = ?;`, id)
|
|
var fren Fren
|
|
err := row.Scan(&fren.Id, &fren.Name)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
return &fren, nil
|
|
}
|
|
|
|
func FindFrenByName(dbConn *sql.DB, name string) (*Fren, error) {
|
|
row := dbConn.QueryRow(`SELECT id, name FROM frens WHERE name = ?;`, name)
|
|
var fren Fren
|
|
err := row.Scan(&fren.Id, &fren.Name)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
return &fren, nil
|
|
}
|