Convert messages.content to JSONB. This is a very disruptive change.

This commit is contained in:
2024-02-28 20:01:52 -05:00
parent 6182ffa1d4
commit 591642efb3
8 changed files with 41 additions and 23 deletions

View File

@ -158,7 +158,7 @@ class TfElement extends LitElement {
async fetch_new_message(id) {
let messages = await tfrpc.rpc.query(
`
SELECT messages.*
SELECT id, previous, author, sequence, timestamp, hash, json(content), signature
FROM messages
JOIN json_each(?) AS following ON messages.author = following.value
WHERE messages.id = ?
@ -221,7 +221,7 @@ class TfElement extends LitElement {
this.tags = await tfrpc.rpc.query(
`
WITH
recent AS (SELECT id, content FROM messages
recent AS (SELECT id, json(content) AS content FROM messages
WHERE messages.timestamp > ? AND json_extract(content, '$.type') = 'post'
ORDER BY timestamp DESC LIMIT 1024),
recent_channels AS (SELECT recent.id, '#' || json_extract(content, '$.channel') AS tag