24 lines
504 B
Go
24 lines
504 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hhhapz/hackathon/models"
|
|
)
|
|
|
|
func (db *DB) Users(ctx context.Context) ([]*models.User, error) {
|
|
return models.Users(ctx, db.DB)
|
|
}
|
|
|
|
func (db *DB) User(ctx context.Context, email string) (*models.User, error) {
|
|
return models.UserByEmail(ctx, db.DB, email)
|
|
}
|
|
|
|
func (db *DB) UpdateUser(ctx context.Context, user *models.User) error {
|
|
if err := user.Upsert(ctx, db.DB); err != nil {
|
|
return fmt.Errorf("could not upsert user: %w", err)
|
|
}
|
|
return nil
|
|
}
|