Show HN: Pg_CRDT – an experimental CRDT extension for Postgres
For quick viewing, here's how it works in Postgres (using Yjs):<p><pre><code>    create table posts (
      id serial primary key,
      content crdt.ydoc default crdt.new_ydoc()
    );
  
    insert into posts (content)
    values (crdt.new_ydoc());

    update posts 
    set content = content || crdt.new_ydoc()
    where id = 1;

</code></pre>
The heavy-lifting is done by the teams at Yjs[0] and Automerge[1], who have re-implemented their JS libs in Rust. This made it possible for us to wrap them into a Postgres extension using pgx[2] (which is fast becoming a de-facto tool at supabase)<p>[0] Yjs: <a href="https://github.com/yjs/yjs" rel="nofollow">https://github.com/yjs/yjs</a><p>[1] Automerge: <a href="https://github.com/automerge/automerge" rel="nofollow">https://github.com/automerge/automerge</a><p>[3] pgx: <a href="https://github.com/tcdi/pgx" rel="nofollow">https://github.com/tcdi/pgx</a>