feat: next
This commit is contained in:
221
server/internal/sqlc/credential.sql.go
Normal file
221
server/internal/sqlc/credential.sql.go
Normal file
@ -0,0 +1,221 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// source: credential.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const deleteCredential = `-- name: DeleteCredential :exec
|
||||
DELETE FROM credential
|
||||
WHERE
|
||||
cred_id = ?1
|
||||
AND
|
||||
user_id = ?2
|
||||
`
|
||||
|
||||
type DeleteCredentialParams struct {
|
||||
ID string
|
||||
UserID int64
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteCredential(ctx context.Context, arg DeleteCredentialParams) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteCredential, arg.ID, arg.UserID)
|
||||
return err
|
||||
}
|
||||
|
||||
const getCredential = `-- name: GetCredential :one
|
||||
SELECT
|
||||
cred_id,
|
||||
cred_public_key,
|
||||
sign_count,
|
||||
transports,
|
||||
user_verified,
|
||||
backup_eligible,
|
||||
backup_state,
|
||||
attestation_object,
|
||||
attestation_client_data,
|
||||
created_at,
|
||||
last_used,
|
||||
user_id
|
||||
FROM credential
|
||||
WHERE
|
||||
cred_id = ?1
|
||||
AND
|
||||
user_id = ?2
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetCredentialParams struct {
|
||||
ID string
|
||||
UserID int64
|
||||
}
|
||||
|
||||
func (q *Queries) GetCredential(ctx context.Context, arg GetCredentialParams) (Credential, error) {
|
||||
row := q.db.QueryRowContext(ctx, getCredential, arg.ID, arg.UserID)
|
||||
var i Credential
|
||||
err := row.Scan(
|
||||
&i.CredID,
|
||||
&i.CredPublicKey,
|
||||
&i.SignCount,
|
||||
&i.Transports,
|
||||
&i.UserVerified,
|
||||
&i.BackupEligible,
|
||||
&i.BackupState,
|
||||
&i.AttestationObject,
|
||||
&i.AttestationClientData,
|
||||
&i.CreatedAt,
|
||||
&i.LastUsed,
|
||||
&i.UserID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getCredentials = `-- name: GetCredentials :many
|
||||
SELECT
|
||||
cred_id,
|
||||
cred_public_key,
|
||||
sign_count,
|
||||
transports,
|
||||
user_verified,
|
||||
backup_eligible,
|
||||
backup_state,
|
||||
attestation_object,
|
||||
attestation_client_data,
|
||||
created_at,
|
||||
last_used,
|
||||
user_id
|
||||
FROM credential
|
||||
WHERE user_id = ?1
|
||||
`
|
||||
|
||||
func (q *Queries) GetCredentials(ctx context.Context, userID int64) ([]Credential, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getCredentials, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Credential
|
||||
for rows.Next() {
|
||||
var i Credential
|
||||
if err := rows.Scan(
|
||||
&i.CredID,
|
||||
&i.CredPublicKey,
|
||||
&i.SignCount,
|
||||
&i.Transports,
|
||||
&i.UserVerified,
|
||||
&i.BackupEligible,
|
||||
&i.BackupState,
|
||||
&i.AttestationObject,
|
||||
&i.AttestationClientData,
|
||||
&i.CreatedAt,
|
||||
&i.LastUsed,
|
||||
&i.UserID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const insertCredential = `-- name: InsertCredential :exec
|
||||
INSERT INTO credential (
|
||||
cred_id,
|
||||
cred_public_key,
|
||||
sign_count,
|
||||
transports,
|
||||
user_verified,
|
||||
backup_eligible,
|
||||
backup_state,
|
||||
attestation_object,
|
||||
attestation_client_data,
|
||||
created_at,
|
||||
last_used,
|
||||
user_id
|
||||
) VALUES (
|
||||
?1,
|
||||
?2,
|
||||
?3,
|
||||
?4,
|
||||
?5,
|
||||
?6,
|
||||
?7,
|
||||
?8,
|
||||
?9,
|
||||
?10,
|
||||
?11,
|
||||
?12
|
||||
)
|
||||
`
|
||||
|
||||
type InsertCredentialParams struct {
|
||||
CredID string
|
||||
CredPublicKey []byte
|
||||
SignCount int64
|
||||
Transports *string
|
||||
UserVerified *bool
|
||||
BackupEligible *bool
|
||||
BackupState *bool
|
||||
AttestationObject []byte
|
||||
AttestationClientData []byte
|
||||
CreatedAt time.Time
|
||||
LastUsed time.Time
|
||||
UserID int64
|
||||
}
|
||||
|
||||
func (q *Queries) InsertCredential(ctx context.Context, arg InsertCredentialParams) error {
|
||||
_, err := q.db.ExecContext(ctx, insertCredential,
|
||||
arg.CredID,
|
||||
arg.CredPublicKey,
|
||||
arg.SignCount,
|
||||
arg.Transports,
|
||||
arg.UserVerified,
|
||||
arg.BackupEligible,
|
||||
arg.BackupState,
|
||||
arg.AttestationObject,
|
||||
arg.AttestationClientData,
|
||||
arg.CreatedAt,
|
||||
arg.LastUsed,
|
||||
arg.UserID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateCredential = `-- name: UpdateCredential :exec
|
||||
UPDATE credential
|
||||
SET
|
||||
last_used = COALESCE(?1, last_used),
|
||||
sign_count = COALESCE(?2, sign_count)
|
||||
WHERE
|
||||
cred_id = ?3
|
||||
AND
|
||||
user_id = ?4
|
||||
`
|
||||
|
||||
type UpdateCredentialParams struct {
|
||||
LastUsed *time.Time
|
||||
SignCount *int64
|
||||
ID string
|
||||
UserID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateCredential(ctx context.Context, arg UpdateCredentialParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateCredential,
|
||||
arg.LastUsed,
|
||||
arg.SignCount,
|
||||
arg.ID,
|
||||
arg.UserID,
|
||||
)
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user