SQLite as a document store, when you need it
SQLite has shipped the JSON1 extension by default since 3.38. You can store JSON in a TEXT column and query into it with SQL functions:
json_extract(col, '$.path')— pull a value out by JSON path.json_each(col)/json_tree(col)— table-valued functions to iterate JSON elements.json_set(col, '$.path', value)/json_remove/json_replace— modify.json_array/json_object/json_group_array— build JSON.
Since 3.45 (Jan 2024), SQLite also supports JSONB — a binary representation that's faster to parse on every access. Store as JSONB when the column is large or queried often.
Tip: Index expressions on extracted JSON paths to make queries fast:
CREATE INDEX idx_meta_status ON events(json_extract(meta, '$.status')). Then WHERE json_extract(meta, '$.status') = 'pending' uses the index.