Caleb
87 posts


@benitambulu_ Cool stuff you building
But i will suggest you make a function that takes two parameters one for the name and JavaScript element you want to save to local storage so you wont keep repeating same code.
Lets connect benita
English

Good morning!
Small progress still counts. What are you working on today?
#BuildInPublic #TechCommunity #Developers #MICBTech
English

Two more layers done on my go api: post and comment repositories
Used Dynamic query building:
- built the queries piece by piece using a string and an args slice.
- Search filter, sort order and pagination all get appended conditionally. args... unpacks everything cleanly into db.Query()
Pagination with COUNT(*) OVER():
- A single query returns both the data and total record count using a window function.
- No second query needed. The MetaData struct calculates current page, last page, next and previous automatically.
Nested comments via self JOIN:
- Comments table has a parent_id column.
- Top level comments have parent_id = NULL.
- Replies point to their parent.
To count replies on a single comment:
LEFT JOIN comments AS replies ON replies.parent_id = c.id
The comments table joins itself. replies is just an alias for the same table filtered differently.
LEFT JOIN vs INNER JOIN:
- Votes and replies use LEFT JOIN
- posts and comments with zero votes or replies still appear. INNER JOIN would hide them.




English












