mirror of
https://github.com/hanzoui/registry-backend.git
synced 2026-10-30 20:30:45 +00:00
20 lines
426 B
Go
20 lines
426 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"registry-backend/ent"
|
|
"registry-backend/ent/user"
|
|
)
|
|
|
|
// UpsertUser creates or updates a user in the database
|
|
func UpsertUser(ctx context.Context, client *ent.Client, firebaseUID string, email string, name string) error {
|
|
return client.User.Create().
|
|
SetID(firebaseUID).
|
|
SetEmail(email).
|
|
SetName(name).
|
|
OnConflictColumns(user.FieldID).
|
|
UpdateEmail().
|
|
UpdateName().
|
|
Exec(ctx)
|
|
}
|