是否可以将 pubnub 聊天消息导出到 postgresql 数据库?
Is it possible to export pubnub chat messages to a postgresql database?
我正在制作一个移动应用程序的原型,我想尽快完成。为此,我使用 pubnub chat engine
.
但是,我计划在 beta 测试结束后迁移到 postgresql 数据库。但我不想丢失已经存储在 pubnub 中的现有数据。是否有可能将我的聊天数据导出到我自己的 postgreSQL 数据库?
将 PubNub 聊天消息导出到您的 PostgeSQL 数据库
While many approaches exist. One is best. Using PubNub Functions. You will asynchronously save messages reliably to your Database. Using an OnAfter Publish Event. Your database needs to be accessible via a secured HTTPS endpoint.
Whosebug 回答: - You will want to Save your JSON Messages to a Private Database 使用链接中描述的方法。 post.
下面引用的示例代码
export default request => {
const xhr = require('xhr');
const post = { method : "POST", body : request.message };
const url = "https://my.company.com/save";
// save message asynchronously
xhr.fetch( url, post ).then( serverResponse => {
// DB Save Success!
}).catch( err => {
// DB Save Failed! handle err
});
return request.ok();
}
我正在制作一个移动应用程序的原型,我想尽快完成。为此,我使用 pubnub chat engine
.
但是,我计划在 beta 测试结束后迁移到 postgresql 数据库。但我不想丢失已经存储在 pubnub 中的现有数据。是否有可能将我的聊天数据导出到我自己的 postgreSQL 数据库?
将 PubNub 聊天消息导出到您的 PostgeSQL 数据库
While many approaches exist. One is best. Using PubNub Functions. You will asynchronously save messages reliably to your Database. Using an OnAfter Publish Event. Your database needs to be accessible via a secured HTTPS endpoint.
Whosebug 回答:
export default request => {
const xhr = require('xhr');
const post = { method : "POST", body : request.message };
const url = "https://my.company.com/save";
// save message asynchronously
xhr.fetch( url, post ).then( serverResponse => {
// DB Save Success!
}).catch( err => {
// DB Save Failed! handle err
});
return request.ok();
}