feat: next
This commit is contained in:
83
server/db/queries/credential.sql
Normal file
83
server/db/queries/credential.sql
Normal file
@ -0,0 +1,83 @@
|
||||
-- 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 = @id
|
||||
AND
|
||||
user_id = @user_id
|
||||
LIMIT 1;
|
||||
|
||||
-- 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 = @user_id;
|
||||
|
||||
-- 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 (
|
||||
@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
|
||||
);
|
||||
|
||||
-- name: UpdateCredential :exec
|
||||
UPDATE credential
|
||||
SET
|
||||
last_used = COALESCE(sqlc.narg('last_used'), last_used),
|
||||
sign_count = COALESCE(sqlc.narg('sign_count'), sign_count)
|
||||
WHERE
|
||||
cred_id = @id
|
||||
AND
|
||||
user_id = @user_id;
|
||||
|
||||
-- name: DeleteCredential :exec
|
||||
DELETE FROM credential
|
||||
WHERE
|
||||
cred_id = @id
|
||||
AND
|
||||
user_id = @user_id;
|
@ -34,6 +34,7 @@ WHERE
|
||||
AND
|
||||
(added <= sqlc.narg('end') OR sqlc.narg('end') IS NULL)
|
||||
)
|
||||
ORDER BY added DESC
|
||||
LIMIT
|
||||
@limit
|
||||
OFFSET
|
||||
|
@ -3,7 +3,8 @@ SELECT
|
||||
id,
|
||||
username,
|
||||
password,
|
||||
profile_picture_id
|
||||
profile_picture_id,
|
||||
webauthn_id
|
||||
FROM user
|
||||
WHERE
|
||||
id = @id
|
||||
@ -14,7 +15,8 @@ SELECT
|
||||
id,
|
||||
username,
|
||||
password,
|
||||
profile_picture_id
|
||||
profile_picture_id,
|
||||
webauthn_id
|
||||
FROM user
|
||||
WHERE
|
||||
username = @username
|
||||
@ -23,10 +25,12 @@ LIMIT 1;
|
||||
-- name: InsertUser :one
|
||||
INSERT INTO user (
|
||||
username,
|
||||
password
|
||||
password,
|
||||
webauthn_id
|
||||
) VALUES (
|
||||
@username,
|
||||
@password
|
||||
@password,
|
||||
@webauthn_id
|
||||
)
|
||||
RETURNING id;
|
||||
|
||||
|
Reference in New Issue
Block a user