是否可以将pubnub聊天消息导出到postgresql数据库?

问题描述 投票:1回答:1

我是一个移动应用程序的原型,我想快速做到。为此,我使用pubnub chat engine

但是,我计划在beta测试结束后迁移到postgresql数据库。但我不想丢失已存储在pubnub中的现有数据。有没有可能将聊天数据导出到我自己的postgreSQL数据库?

postgresql pubnub
1个回答
1
投票

Export PubNub Chat Messages to your PostgeSQL Database

虽然存在许多方法。一个是最好的。使用PubNub Functions。您将异步地将消息可靠地保存到数据库中。使用OnAfter发布事件。您的数据库需要通过安全的HTTPS端点访问。

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();
}
© www.soinside.com 2019 - 2024. All rights reserved.