mirror of
https://github.com/rjNemo/auth
synced 2026-06-06 00:16:40 +00:00
117 lines
2.9 KiB
Go
117 lines
2.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: user_oauth_accounts.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createUserOAuthAccount = `-- name: CreateUserOAuthAccount :one
|
|
INSERT INTO user_oauth_accounts (user_id, provider, subject, email, email_verified, profile)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
RETURNING id, user_id, provider, subject, email, email_verified, profile, created_at, updated_at
|
|
`
|
|
|
|
type CreateUserOAuthAccountParams struct {
|
|
UserID uuid.UUID `json:"user_id"`
|
|
Provider string `json:"provider"`
|
|
Subject string `json:"subject"`
|
|
Email pgtype.Text `json:"email"`
|
|
EmailVerified bool `json:"email_verified"`
|
|
Profile []byte `json:"profile"`
|
|
}
|
|
|
|
func (q *Queries) CreateUserOAuthAccount(ctx context.Context, arg CreateUserOAuthAccountParams) (UserOauthAccount, error) {
|
|
row := q.db.QueryRow(ctx, createUserOAuthAccount,
|
|
arg.UserID,
|
|
arg.Provider,
|
|
arg.Subject,
|
|
arg.Email,
|
|
arg.EmailVerified,
|
|
arg.Profile,
|
|
)
|
|
var i UserOauthAccount
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Provider,
|
|
&i.Subject,
|
|
&i.Email,
|
|
&i.EmailVerified,
|
|
&i.Profile,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserOAuthAccountByProviderSubject = `-- name: GetUserOAuthAccountByProviderSubject :one
|
|
SELECT id, user_id, provider, subject, email, email_verified, profile, created_at, updated_at
|
|
FROM user_oauth_accounts
|
|
WHERE provider = $1 AND subject = $2
|
|
`
|
|
|
|
type GetUserOAuthAccountByProviderSubjectParams struct {
|
|
Provider string `json:"provider"`
|
|
Subject string `json:"subject"`
|
|
}
|
|
|
|
func (q *Queries) GetUserOAuthAccountByProviderSubject(ctx context.Context, arg GetUserOAuthAccountByProviderSubjectParams) (UserOauthAccount, error) {
|
|
row := q.db.QueryRow(ctx, getUserOAuthAccountByProviderSubject, arg.Provider, arg.Subject)
|
|
var i UserOauthAccount
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Provider,
|
|
&i.Subject,
|
|
&i.Email,
|
|
&i.EmailVerified,
|
|
&i.Profile,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listUserOAuthAccountsByUserID = `-- name: ListUserOAuthAccountsByUserID :many
|
|
SELECT id, user_id, provider, subject, email, email_verified, profile, created_at, updated_at
|
|
FROM user_oauth_accounts
|
|
WHERE user_id = $1
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListUserOAuthAccountsByUserID(ctx context.Context, userID uuid.UUID) ([]UserOauthAccount, error) {
|
|
rows, err := q.db.Query(ctx, listUserOAuthAccountsByUserID, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []UserOauthAccount
|
|
for rows.Next() {
|
|
var i UserOauthAccount
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Provider,
|
|
&i.Subject,
|
|
&i.Email,
|
|
&i.EmailVerified,
|
|
&i.Profile,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|