【问题标题】:React Native with mongdb realm, Realm.App(config) always returns empty objectReact Native 与 mongodb 领域,Realm.App(config) 总是返回空对象
【发布时间】:2020-09-08 16:14:57
【问题描述】:

以下是 MongoDB 领域文档中给出的启动应用程序的快速启动代码。

import Realm from 'realm';
    
let app;
    
// Returns the shared instance of the Realm app.
export function getRealmApp() {
    if (app === undefined) {
        const appId = 'demo'; // Set Realm app ID here.
        
        const appConfig = {
            id: appId,
            timeout: 10000,
            app: {
                name: 'demo',
                version: '0',
            },
        };
        
        app = new Realm.App(appConfig);        
    }
    
    return app;
}

当我调用该函数时,我总是得到:

空对象{}

领域版本:"^10.0.0-beta.12"

【问题讨论】:

    标签: react-native realm realm-mobile-platform mongodb-realm


    【解决方案1】:

    这是我的回答from another SO post。我相信问题是在他们这边,而不是在你这边;无法直接打印对象。这不仅限于app 对象。

    开发人员建议使用.toJSON() 作为解决方法。见this post from the MongoDB Developer forum.

    我在将任何 Realm 对象转换为可打印对象时遇到了一些麻烦 字符串;我总是像你一样得到 {}。我认为这可能是相关的 到他们 GitHub 上的这个(未解决的)任务。

    同样,Realm 的身份验证存在一些错误 系统。我正在尝试获取电子邮件/密码、Facebook 和 Google 在我的应用程序中进行身份验证,但目前所有这些似乎 在 Realm 一方被打破。

    以下是他们 GitHub 上的一些相关问题,您可以关注这些问题 解决方案。

    Facebook
    Google
    Email/pass (fixed, but not released in the latest beta)
    

    我没有任何关于 JWT 的具体信息,但鉴于这些 其他身份验证问题很可能没有问题 你的身边。我建议在他们的存储库上打开一个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 2016-11-28
      • 1970-01-01
      • 2016-09-27
      • 2020-02-14
      • 1970-01-01
      相关资源
      最近更新 更多