sql.js
sql.js copied to clipboard
any callbacks available?
hello - are any callbacks available? i want to have something where an INSERT, UPDATE, or DELETE is called, i can have it trigger some registered callback hooks.
sql.js 没有导出 sqlite3_update_hook 等接口。 我想尝试导出接口, 但对处理cpp与js数据转换这个过程不太熟悉。 但是我发现了一个简单可用的方式, 添加sqlite自定义函数再使用触发器.
sql.js does not export interfaces such as sqlite3_update_hook. I want to try to export the interface, but I am not familiar with the process of dealing with cpp and js data conversion. But I found a simple and usable way, add sqlite custom function and then use trigger.
举个例子
for examples
db.create_function("TriggerUnily",(data)=>{
console.log("TriggerUnily",data);
});
CREATE TRIGGER "main"."TriggerUnily"
AFTER DELETE
ON "file"
BEGIN
-- Type the SQL Here.
select TriggerUnily(old.id) as "";
END;
sqlite trigger https://www.sqlite.org/lang_createtrigger.html