Firestore/ionic 错误 - 调用 .map 时方法 snapshotChanges return 未定义
Firestore/ionic error - Method snapshotChanges return undefined when call .map
我有一个 ionic v4 应用程序。当用户导航到配置文件页面时单击 link (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 return undefined?有什么想法或建议吗?
升级到^5.0.0-rc.9后终于变成这样了:当我们使用rxjs map时,我们应该使用pipe operator
尝试ref.pipe(map(action =>{......}))
我有一个 ionic v4 应用程序。当用户导航到配置文件页面时单击 link (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 return undefined?有什么想法或建议吗?
升级到^5.0.0-rc.9后终于变成这样了:当我们使用rxjs map时,我们应该使用pipe operator
尝试ref.pipe(map(action =>{......}))