【问题标题】:Inserting Data when google cloud firestore is offline [duplicate]google cloud firestore离线时插入数据[重复]
【发布时间】:2018-02-19 08:21:44
【问题描述】:

我有以下代码,当应用程序在线时可以正常工作。但是,当离线时,承诺解决或拒绝的代码不会被执行。我已经用谷歌搜索了 cloud firestore 的文档。我可以找到离线查询数据的示例,但没有在应用离线时插入数据的示例。仅包括以下相关部分。

db.collection('GroceryLists').doc().set(post).then(function () {
            callback();
            console.log('committed to the database');
            return Promise.resolve('commited to the database');
        }).catch(function (error) {
            //sometimes you get this error in the offline phase
            console.log('error is ', error);
            return Promise.reject('error is ' + error);
        });

【问题讨论】:

    标签: javascript firebase google-cloud-firestore


    【解决方案1】:

    只有在服务器上提交或拒绝数据后才会触发完成承诺。

    当数据提交到客户端数据库时没有事件,Firestore 将其视为临时缓存。

    另见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-17
      • 2021-05-10
      • 2021-04-09
      • 1970-01-01
      • 2018-03-18
      相关资源
      最近更新 更多