Full schema (for Postgres)
board_subscriptions
table.
To start with, in our PowerSync Sync Rules, we define a bucket and sync the posts. The parameter query is defined using the board_subscriptions
table:
posts
table. This means conceptually we can add comments to the same board bucket. With general SQL, the query could be:
board_id
from the start, so post_topics
is simple in our Sync Rules:
post_topics
: (Postgres example)
topics
table itself, as everything is included in post_topics
. Assuming the topic label never or rarely changes, this could be a good solution.
Next up, we want to sync the relevant user profiles, so we can show it together with comments and posts. For simplicity, we sync profiles for all users subscribed to a board.
One option is to add the author name to each board subscription, similar to what we’ve done for topics
: (Postgres example)
users
table directly. To sync user profiles directly in the bucket for the board, we need a new array.
Adding an array to the schema in Postgres:
Postgres trigger to update subscribed_board_ids
subscribed_board_ids
array in Postgres becomes slower.