Replies: 3 comments 4 replies
-
|
Update: A Twitter follower (PavitraGolchha) kindly pointed out to me that SQLite has a Date Change Notification that could be exposed via Bun runtime. |
Beta Was this translation helpful? Give feedback.
-
You want to log info for monitoring management or what ? |
Beta Was this translation helpful? Give feedback.
-
|
its possible to do such thing using sqlite update hook. but i found that its very lacking. i found that its easier to just register a function and call it from triggers. but to register a function you need to register it before opening any database connection and you cant register variadic function (or perhaps i just don't know how to do so). reference: https://sqlite.org/c3ref/update_hook.html sqlite triggers sample create trigger session_insert_notify after insert on session
begin
select session_change_notify('insert',
null,
new.id, new.mac_address, new.active, new.verified, new.expiration, new.time_stamp
);
end;
create trigger session_update_notify after update on session
begin
select session_change_notify('update',
old.id,
new.id, new.mac_address, new.active, new.verified, new.expiration, new.time_stamp
);
end;
create trigger session_delete_notify after delete on session
begin
select session_change_notify('delete',
old.id,
null, null, null, null, null, null
);
end; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would love to see a thin layer that enables real-time event subscriptions API around SQLite for listening to changes on the database for different types of actions such as inserts or updates, deletes, watching changes on a specific record, etc.
I currently leverage Pocketbase for a local instance of a real-time database that uses SQLite, but to have this kind of functionality as a native feature of Bun would be amazing, if it makes sense.
Curious of this feature idea would be a good one for the Bun project. I don't believe it would be very difficult and if I had some extra time, I might consider seeing if I could get a basic implementation working. I've not written anything in Rust yet.
Let's discuss.
Beta Was this translation helpful? Give feedback.
All reactions