weiro/_test-site/posts/2026/02/19-about-a-db.md
2026-02-19 22:29:44 +11:00

18 lines
1.1 KiB
Markdown

---
date: 2026-02-19T22:17:00+11:00
title: About a DB
slug: /2026/02/19/about-a-db
---
Hello again.
This is the second post with Weiro. This evening, I wondered how best to manage the storage of these posts.
I know that a few developers have opted in for files on a file system. It's an interesting approach, and probably
a good one for most. But I couldn't get my head around effective sorting and filtering. Having a largish blog,
say 3000 posts or so, would be difficult to leave up to the file system alone, especially when it comes to
paging and searching in the posts list.
So I opted for a database. I'm using a [Go port of sqlite3](https://pkg.go.dev/modernc.org/sqlite).
with [SQLC](https://github.com/kyleconroy/sqlc) to generate the queries. There's still no UI, so what the current
version of Weiro does is import the site from Markdown files, load it into the database, then reads it from the
database and publishes it to the file system. I was able to repurpose the existing code as an import service, making
it potentially quite useful even when the bulk of the post is managed via the frontend.