【问题标题】:Firestore/ionic error - Method snapshotChanges return undefined when call .mapFirestore/ionic 错误 - 调用 .map 时方法 snapshotChanges 返回未定义
【发布时间】:2019-10-12 00:50:59
【问题描述】:

我有一个 ionic v4 应用程序。当用户点击链接(routerLink="/profile")导航到配置文件页面时,我对 firestore 进行查询,一切都很好,查询是:

let ref = this.asf.collection('posts', ref => ref
  .where('creatorId', '==', creatorId)
  .where("type","==","N")
  .orderBy("createAt", "desc")   
  .limit(count)
).snapshotChanges();
console.log("-----------------");
console.log(ref);
console.log(ref.map);    
console.log("-----------------");
ref.map(actions => {
  return actions.map(a => {
    const data = a.payload.doc.data();
    const id = a.payload.doc.id;
    return { id, ...data };
  });
});

但是,当用户通过在浏览器中输入 url 进入时,ref.map 是未定义的。

为什么当用户在浏览器中输入 url 进入时 ref.map 返回 undefined?有什么想法或建议吗?

【问题讨论】:

    标签: angular firebase google-cloud-firestore ionic4 angularfire2


    【解决方案1】:

    升级到^5.0.0-rc.9后,终于是这样了:当我们使用rxjs map时,我们应该使用管道操作符。

    试试ref.pipe(map(action =>{......}))

    【讨论】:

      猜你喜欢
      • 2021-08-16
      • 1970-01-01
      • 2021-12-10
      • 1970-01-01
      • 2020-06-16
      • 2023-03-16
      • 2013-01-12
      • 1970-01-01
      • 2019-09-20
      相关资源
      最近更新 更多