Node.js Firebase startAfter不适用于doc ref
我的发言如下: 我有如下代码Node.js Firebase startAfter不适用于doc ref,node.js,firebase,google-cloud-firestore,google-cloud-functions,Node.js,Firebase,Google Cloud Firestore,Google Cloud Functions,我的发言如下: 我有如下代码 async List(query: any): Promise<Array<any>> { let collectionQuery = super.GetCollectionReference(); if (query.VideoChannelId) { collectionQuery = collectionQuery.where( "VideoChannel.Id", "==",
async List(query: any): Promise<Array<any>> {
let collectionQuery = super.GetCollectionReference();
if (query.VideoChannelId) {
collectionQuery = collectionQuery.where(
"VideoChannel.Id",
"==",
query.VideoChannelId
);
}
let startAfterDoc: any = "";
if (query.StartAfter) {
startAfterDoc = await super.GetDocumentReference(query.StartAfter);
}
collectionQuery = collectionQuery
.orderBy(query.OrderBy, "desc")
.startAfter(startAfterDoc)
.limit(query.Limit);
let items = await super.List(collectionQuery);
return items;
}
异步列表(查询:any):承诺{
让collectionQuery=super.GetCollectionReference();
if(query.VideoChannelId){
collectionQuery=collectionQuery.where(
“VideoChannel.Id”,
"==",
query.VideoChannelId
);
}
让startAfterDoc:any=“”;
if(query.StartAfter){
startAfterDoc=wait super.GetDocumentReference(query.StartAfter);
}
collectionQuery=collectionQuery
.orderBy(query.orderBy,“desc”)
.startAfter(startAfterDoc)
.limit(查询.limit);
let items=wait super.List(collectionQuery);
退货项目;
}
和实用方法:
GetDocumentReference(id: string): any {
return this.GetCollectionReference().doc(id);
}
async GetDocumentSnapshot(id: string): Promise<any> {
return await this.GetDocumentReference(id).get();
}
GetCollectionReference(): any {
return this.db.collection(this.CollectionName);
}
GetDocumentReference(id:string):任意{
返回此.GetCollectionReference().doc(id);
}
异步GetDocumentSnapshot(id:string):承诺{
return wait this.GetDocumentReference(id.get();
}
GetCollectionReference():任何{
返回this.db.collection(this.CollectionName);
}
不管我传递给query.start的值是什么,它总是返回集合中的顶级文档。
我很确定存在id为query.StartAfter的文档
如果我使用GetDocumentSnapshot
而不是GetCollectionReference
,那么我在firebase API上得到了解析错误
已为查询.OrderBy
(CreateDate)和Id字段添加索引
我可能会错过什么