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

标签 postgresql pubnub

我正在制作一个移动应用程序的原型(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/

相关文章:

database - 将 Heroku 应用程序指向 AWS RDS 数据库

SQL更新同一张表中的缺失值

php - 处理传入 JSONObject 的字符串

javascript - 消息: 'Forbidden' when trying to add channel to channel group in PubNub

postgresql - 如何在 Postgres 9.4 JSONB 列中执行不区分大小写的搜索?

sql - 使用子查询优化聚合 postgres 查询

postgresql - 使用 PostgreSQL 触发器对数据进行动态审计

javascript - pubnub 和 head.js

android - Pubnub 3.7.2 禁用日志记录 Android SDK

javascript - pubnub 只能在 LAN 上运行吗?