31 lines
694 B
Go
31 lines
694 B
Go
package google
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"ersteller-lib"
|
|
"github.com/doug-martin/goqu/v9"
|
|
)
|
|
|
|
func (r *GoogleAuthRepository) ReadByUserId(userId int) (GoogleAuth, error) {
|
|
ersteller_lib.Debug("Getting GoogleAuth by userId", userId)
|
|
sql, args, _ := r.dialect.From("googleAuth").
|
|
Prepared(true).
|
|
Select(r.getSelectColumns()...).
|
|
Where(goqu.Ex{
|
|
"user_id": userId,
|
|
}).
|
|
ToSQL()
|
|
|
|
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
|
if err != nil {
|
|
ersteller_lib.Error("Failed to get GoogleAuth: ", err)
|
|
}
|
|
defer rows.Close()
|
|
if rows.Next() {
|
|
item, _, err := r.rowToItem(rows, false)
|
|
return item, err
|
|
}
|
|
return GoogleAuth{}, errors.New("no rows found")
|
|
}
|