phoneof/database/frens.go

34 lines
638 B
Go
Raw Normal View History

2025-01-03 01:47:07 -08:00
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
}