Comment

Comment by kiwicopple

For quick viewing, here's how it works in Postgres (using Yjs):

    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;

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)

[0] Yjs: https://github.com/yjs/yjs

[1] Automerge: https://github.com/automerge/automerge

[3] pgx: https://github.com/tcdi/pgx

parent kiwicopple 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton