Categorygithub.com/cs-tungthanh/Bank_Golang
modulepackage
0.0.0-20240402161841-5da16fa789ac
Repository: https://github.com/cs-tungthanh/bank_golang.git
Documentation: pkg.go.dev

# README

Bank-Golang

This project I used for learning Go and other techniques to improve my skills.

User Story

detail

Dependencies

detail

  • golang-migrate
  • sqlc: v1.25.0
  • mockgen

Stages

1. Design Database Schema

https://dbdiagram.io/d/6208c1dd85022f4ee584df9c

There are 3 tables:

  1. Account table:
  • A person can has many accounts but one account only have one currency.
  1. Entries table: used for recording all history of changes to the account balance
  • One account can have many entries
  1. Transfers table:

Indexing to the DB:

  • we might want to search an account by owner name
  • we might want to retrieve all transfers that going out/into of an account

Database graph

BEGIN;
UPDATE Table1 ... WHERE name = 'Alice';
SAVEPOINT my_savepoint_label;
UPDATE Table2 ... WHERE name = 'Bob';
-- oops ... forget that and use Wally's account
ROLLBACK TO my_savepoint_label;
UPDATE ... WHERE name = 'Wally';
COMMIT;
BEGIN;

INSERT INTO transfers (from_account_id, to_account_id, amount) VALUES (6,7,10) RETURNING *;

INSERT INTO entries (account_id, amount) VALUES (6, -10) RETURNING *;
INSERT INTO entries (account_id, amount) VALUES (7, 10) RETURNING *;

SELECT * FROM accounts WHERE id = 6 FOR UPDATE;
UPDATE accounts SET balance=689 WHERE id=6 RETURNING *;

SELECT * FROM accounts WHERE id = 7 FOR UPDATE;
UPDATE accounts SET balance=791 WHERE id=7 RETURNING *;

ROLLBACK;

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author

# Interfaces

No description provided by the author