- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我想使用 Heroku、PostgreSQL 和 Node.js,并将其设置为每当我在我的 postgres 数据库中添加一条记录时,Node.js 都会将该行的内容打印到控制台。
我正尝试按照这些指示进行设置:
http://lheurt.blogspot.com/2011/11/listen-to-postgresql-inserts-with.html
http://bjorngylling.com/2011-04-13/postgres-listen-notify-with-node-js.html
这是 node.js 代码
var pg = require('pg');
conString = '/*my database connection*/';
var client = new pg.Client(conString);
client.connect(function(err) {
if(err) {
return console.error('could not connect to postgres', err);
}
client.connect();
client.query('LISTEN "loc_update"');
client.on('notification', function(data) {
console.log(data.payload);
});
});
这是在postgres数据库上执行的函数
String function = "CREATE FUNCTION notify_trigger() RETURNS trigger AS $$ "
+ "DECLARE "
+ "BEGIN "
+ "PERFORM pg_notify('loc_update', TG_TABLE_NAME || ',longitude,' || NEW.longitude || ',latitude,' || NEW.latitude );"
+ "RETURN new;"
+ "END;"
+ "$$ LANGUAGE plpgsql;";
String trigger = "CREATE TRIGGER location_update AFTER INSERT ON device "
+ "FOR EACH ROW EXECUTE PROCEDURE notify_trigger();";
上传到 Heroku 后,我收到此错误。我做错了什么?
2013-10-13T22:40:21.470310+00:00 heroku[web.1]: Starting process with command `node web.js`
2013-10-13T22:40:23.697134+00:00 app[web.1]:
2013-10-13T22:40:23.727555+00:00 app[web.1]: events.js:72
2013-10-13T22:40:23.727822+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-10-13T22:40:23.727822+00:00 app[web.1]: ^
2013-10-13T22:40:23.784576+00:00 app[web.1]: error: invalid frontend message type 0
2013-10-13T22:40:23.784576+00:00 app[web.1]: at p.parseE (/app/node_modules/pg/lib/connection.js:473:11)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at p.parseMessage (/app/node_modules/pg/lib/connection.js:348:17)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:84:22)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:117:20)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at Socket.<anonymous> (_stream_readable.js:746:14)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:92:17)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at emitReadable_ (_stream_readable.js:408:10)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at emitReadable (_stream_readable.js:404:5)
2013-10-13T22:40:23.784576+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:165:9)
2013-10-13T22:40:23.784787+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:127:10)
2013-10-13T22:40:25.128299+00:00 heroku[web.1]: Process exited with status 8
2013-10-13T22:40:25.133342+00:00 heroku[web.1]: State changed from starting to crashed
最佳答案
尝试重命名变量:
String function = "CREATE FUNCTION notify_trigger() RETURNS trigger AS $$ ";
到
String variableFunction = "CREATE FUNCTION notify_trigger() RETURNS trigger AS $$ ";
函数是一个保留字。
如果错误仍然存在,请尝试在本地主机上模拟相同的环境。
关于javascript - Node.js 和 postgres 听,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19351216/
是否可以使用回调来监听 CSS 变量的变化?像这样的东西: documentElement.addListener('css-var-main-background-color', () => {
我有应该运行laravel队列的docker镜像。在图像中,我有php artisan queue:listen命令,但是当我启动容器时,什么也没有发生,并且容器在运行。 这是基本图片 FROM ph
我正在尝试下载视频以在 exoplayer 中离线播放,但我不知道如何收听 onDownloadComplete。在 exoplayer 文档中,他们说 DownloadService是一个环绕 an
如果我在 View Controller 上有 2 个通知有 2 个这样的观察者,这是否合适: [NSNotificationCenter defaultCenter] addObserver:sel
尝试创建服务器-客户端应用程序时,我在设置服务器端连接时遇到了一些麻烦。设置套接字并bind()ing 套接字后,我的listen() 调用失败并显示错误消息 listen: Invalid argu
我有一个从不同模块更新的 UITextField(我将我的 UITextField 传递给上面提到的模块以填充它)。我需要一种方法来识别 UITextField 的文本值何时在 UITextField
假设我有单独的 Django 和 Tornado 应用程序。这就是我想要实现的目标: Django 收到一些 POST 请求并通知 Tornado 应用程序,以便 Tornado 应用程序可以向其连接
在一个模块上,我需要监听 url 的变化,所以我写了一个简单的代码: componentDidMount(){ history.listen( location => {
我想断言,当单击禁用按钮时,不会触发其 onClick 事件。我如何用 enzyme 来做到这一点?请参阅下面的示例代码。谢谢! sampleButton.jsx: import React from
我遇到了这个问题,我有一个部分(“.aboutsection”)一开始是隐藏的,需要在点击网页上的某个点时显示出来,然后开始为 .slideDown() 设置动画。我让它工作了,但每次我滚动到那个特定
我有一个关于 JS 中的键盘事件的问题。 首先,请不要回答我使用 jQuery 方法,我知道其中的大部分(绑定(bind)/解除绑定(bind),开/关,一个......)但我使用内部框架必须在没有
shiny 中是否有一个暴露的(甚至可能是非暴露的)函数会告诉我什么时候 react 失效?示例草稿: ui.R selectInput('select', ...) 服务器.R myfunc <-
我正在使用 PostgreSQL 数据库并应用它的 LISTEN/NOTIFY 功能。所以我的监听器在我的 AS(应用程序服务器)上,我在我的数据库上配置了触发器,这样当在表上执行 CRUD 操作时,
设置:一个简约的 Linux(华硕路由器上的 OpenWRT),一个 USB 键盘(假设我知道设备名称,如/dev/hiddev0) 一个目标:编写一个 python(或 shell,在这种情况下我可
我使用 Fragment 让用户在我的 Android 应用程序中输入信息。如果输入了信息,我希望在用户按下“后退”键时向用户发送警告。如果他确认要放弃更改,则必须弹出 Fragment。如果他取消放
这是我的 HTML/CSS 当前的样子: 这是我想要它的样子: 我如何修改下面的 HTML/CSS 以使其显示我想要的样子? HTML: CSS: .upda
我想使用 Heroku、PostgreSQL 和 Node.js,并将其设置为每当我在我的 postgres 数据库中添加一条记录时,Node.js 都会将该行的内容打印到控制台。 我正尝试按照这些指
在今天晚上之前我卸载了 vscode 并再次安装后一切正常我在尝试运行 npm run app 时遇到了这个问题我不知道如何解决这个问题我试图运行 vs 代码和命令提示符或 bash 使用以管理员身份
我目前正面临一个我无法解决的错误,我已经苦苦挣扎了几个小时。 我正在使用以下版本: Node :8.11.3 express :4.16.3 Jest :22.2.2 Mongoose :5.2.3
我正在尝试为网站上的特定 url 部署使用 node.js 开发的服务器。 已经有一个服务器可以覆盖网站上的所有网址,我希望我的唯一答案是 the_website_url/my_specific_ur
我是一名优秀的程序员,十分优秀!