监听 Gun 服务器中的数据变化
Listen data changes in Gun server
如何监听Gun服务器数据库发生的变化:
我的服务器正在监听如下
var Gun = require('gun');
var server = http.createServer();
var gun = Gun({web: server});
server.listen(port, function () {
console.log('Server listening on ...')
})
在从 Gun 客户端输入数据时,我的 data.json 文件已更新。现在我需要监听数据库中发生的所有变化。我认为在一个 perticuler 节点上我可以使用 gun.on
方法来收听。我们可以听取来自客户的全部变更/变更请求吗?
@ajmal-m-a 是的,通过 "wire spec"(您需要了解图表格式,这是一个技术讲座,我会在舞台上用 30 分钟解释它):
gun.on('in', function(msg){})
其中 gun 是词根。
Note: You'll need to understand how to handle the middleware event hook system - your listener will need to remember to call this.to.next(msg)
.
这是一个很好且简单的资源:
https://github.com/zrrrzzt/bullet-catcher
这有帮助吗?
(不好意思回答问题晚了,我们当时正要去开会,被一堆邮件淹没了)
如何监听Gun服务器数据库发生的变化:
我的服务器正在监听如下
var Gun = require('gun');
var server = http.createServer();
var gun = Gun({web: server});
server.listen(port, function () {
console.log('Server listening on ...')
})
在从 Gun 客户端输入数据时,我的 data.json 文件已更新。现在我需要监听数据库中发生的所有变化。我认为在一个 perticuler 节点上我可以使用 gun.on
方法来收听。我们可以听取来自客户的全部变更/变更请求吗?
@ajmal-m-a 是的,通过 "wire spec"(您需要了解图表格式,这是一个技术讲座,我会在舞台上用 30 分钟解释它):
gun.on('in', function(msg){})
其中 gun 是词根。
Note: You'll need to understand how to handle the middleware event hook system - your listener will need to remember to call
this.to.next(msg)
.
这是一个很好且简单的资源:
https://github.com/zrrrzzt/bullet-catcher
这有帮助吗?
(不好意思回答问题晚了,我们当时正要去开会,被一堆邮件淹没了)