我正在制作一个移动应用程序的原型(prototype),我想尽快完成。为此,我正在使用 pubnub 聊天引擎
。
但是,我计划在 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.
Stackoverflow 答案:PubNub: What is the right way to log all published message to my db - 你会想 Save your JSON Messages to a Private Database使用链接中描述的方法。本文下方引用的示例代码。
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();
}
关于postgresql - 是否可以将 pubnub 聊天消息导出到 postgresql 数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49018929/