【发布时间】:2020-01-27 15:19:09
【问题描述】:
使用 ff 代码得到 ff 错误: 错误:
{"code":"failed-precondition","name":"FirebaseError","__zone_symbol__currentTask":{"type":"macroTask","state":"notScheduled","source":"setTimeout","zone":"angular","cancelFn":null,"runCount":0}}
我的代码:
getOldPosts(forum_id: string, user_id: string, start_key?: string): Promise<Posts[]> {
return new Promise((resolve, reject) => {
let olderPosts: Posts[] = [];
let _5daysAgo = this.dateTime.getFiveDaysAgoDate();
const postsRef = this.afirestore.collection<Posts>('posts').ref;
const query = start_key == undefined || start_key == null
? postsRef.where('createdDate', '<=', _5daysAgo).where('forumId', '==', forum_id).where('memberId', '==', user_id)
: postsRef.where('createdDate', '<=', _5daysAgo).where('forumId', '==', forum_id).where('memberId', '==', user_id).startAt(start_key).limit(50);
query.get().then(
res => {
res.docs.forEach(doc => {
olderPosts.push(doc.data() as ForumPosts);
});
resolve(olderPosts.reverse());
},
err => {
reject(err);
}
);
});
}
我似乎无法弄清楚为什么会发生这种情况。我试过在谷歌上搜索,但我似乎没有找到解决方案。我做错了什么?
谢谢。
【问题讨论】:
标签: javascript firebase google-cloud-platform google-cloud-firestore ionic3