SQLite as a Document Database (2020)(dgl.cx)
252 points by lioeters 16 days ago | 56 comments
tl;dr: SQLite 3.31.0 (Jan 2020) added generated columns, which combined with existing JSON support effectively turns it into a document database. You can insert raw JSON into a TEXT column and define VIRTUAL or STORED columns that extract fields via `json_extract`, which can then be indexed and constrained (NOT NULL, etc.) like normal columns. This enables a workflow where you dump JSON payloads (e.g. webhooks) into a table and progressively add extracted columns and indexes via ALTER TABLE as needed.
HN Discussion:
  • Personal experience confirming SQLite works well as a document database in production
  • ~Questions the article's example choice of extracting only one JSON field rather than storing the full document
  • Notes this approach isn't novel and references prior work by others like Simon Willison
  • Praises SQLite's unique versatility for combining JSON, blobs, FTS, and vector search
  • Semantic pushback questioning whether JSON storage really qualifies as a 'document database'