hackathon/db/user.go

24 lines
504 B
Go

package db
import (
"context"
"fmt"
"github.com/hhhapz/hackathon/models"
)
2021-09-30 10:32:18 +07:00
func (db *DB) Users(ctx context.Context) ([]*models.User, error) {
return models.Users(ctx, db.DB)
}
2021-09-30 10:32:18 +07:00
func (db *DB) User(ctx context.Context, email string) (*models.User, error) {
return models.UserByEmail(ctx, db.DB, email)
}
2021-09-30 10:32:18 +07:00
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)
}
2021-09-30 10:32:18 +07:00
return nil
}