-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed account query to change the updateAccount func
- Loading branch information
1 parent
69c195f
commit 56ce9fb
Showing
7 changed files
with
148 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
-- name: CreateAccount :one | ||
insert into accounts( | ||
INSERT INTO accounts ( | ||
owner, | ||
balance, | ||
currency | ||
)values( | ||
$1,$2,$3 | ||
) VALUES ( | ||
$1, $2, $3 | ||
) RETURNING *; | ||
|
||
|
||
-- name: GetAccount :one | ||
select * from accounts where id=$1 limit 1; | ||
SELECT * FROM accounts | ||
WHERE id = $1 LIMIT 1; | ||
|
||
-- name: GetAccountForUpdate :one | ||
SELECT * FROM accounts | ||
WHERE id = $1 LIMIT 1 | ||
FOR NO KEY UPDATE; | ||
|
||
-- name: ListAccounts :many | ||
select * from accounts order by id limit $1 offset 2; | ||
SELECT * FROM accounts | ||
WHERE owner = $1 | ||
ORDER BY id | ||
LIMIT $2 | ||
OFFSET $3; | ||
|
||
-- name: UpdateAccount :one | ||
UPDATE accounts | ||
SET balance = $2 | ||
WHERE id = $1 | ||
RETURNING *; | ||
|
||
-- name: UpdateAccount :exec | ||
update accounts set balance= $2 where id =$1; | ||
-- name: AddAccountBalance :one | ||
UPDATE accounts | ||
SET balance = balance + sqlc.arg(amount) | ||
WHERE id = sqlc.arg(id) | ||
RETURNING *; | ||
|
||
-- name: DeleteAccount :exec | ||
delete from accounts where id = $1; | ||
DELETE FROM accounts | ||
WHERE id = $1; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.