Kirby blocks + comments saved in SQLite

Hi all!

I’m back to work with kirby on a new project after long time.

We plan to have a website where the user can comment on anything that’s part of an article:

  • texts
  • images
  • videos
  • audios

For each block the user can comment on the entire block or select a portion of it (for text an offset, for audio a clip, etc). So far so good.

To store comments I thought to use SQLite (or eventually PostgreSQL) by:

  • outputting the kirby block ID to the DOM as a data-attribute
  • use that ID to reference the comment in the table

I’m sharing all this to ask if anyone tried a similar setup before? I think one possible thing to figure out would be concurrent writing on SQLite, but I am more concerned / curious about if creating a relationship between kirby blocks and a SQL db like this is good?

Thanks and happy to report back the way we handled this.

Wow, this is a great write-up: Content from a database | Kirby CMS.

Haven’t done that, but I would just try it. If you are able to wire up all the CRUD stuff, it’s easy to switch out the database in case you get into trouble with concurrent writing, but as far as I know, SQlite can deal with that. And your feature doesn’t sound like something a few thousand user use at the same time.
And I can’t say with certainty, but I expect the block IDs to be unique and never change (since they are uuids anyway) so creating a relation between blocks and data from your DB should be no problem.

1 Like

I agree with @marcus-at-localhost, should work fine.

https://www.sqlite.org/lockingv3.html

Thanks both, I’ll go with it. I’ll report back when something is done!