Hacker News new | ask | show | jobs
by pqyzwbq 1379 days ago
pocketbase is great, I used it in several personal projects, and I really like it

https://github.com/pocketbase/pocketbase

PocketBase is an open source Go backend, consisting of:

  * embedded database (SQLite) with realtime subscriptions

  * built-in files and users management

  *convenient Admin dashboard UI

  *and simple REST-ish API
1 comments

How are they handling real time subscriptions? Like, how do they figure out when a row is updated? Postgres has replication functionality, but how are they achieving same with SQLite?
The document for pocketbase's realtime is: https://pocketbase.io/docs/api-realtime/

The Realtime API is implemented via Server-Sent Events (SSE). Generally, it consists of 2 operations:

  * establish SSE connection

  * set client subscriptions
SSE events are sent for create, update and delete record operations.

Pocketbase is mainly a single application with SQLite embedded, so, whenever you update records through PocketBase's API, the main application always knows that.

This is different with postgres, since it may be connected by several different applications/servers remotely.

> Like, how do they figure out when a row is updated?

AFAICT because you can only update a row via the UI, it's easy to tell when a row is updated.

But if you're talking about raw SQLite, there's [1].

[1] https://www.sqlite.org/c3ref/update_hook.html