Angular Firestore 中的 Query<DocumentData> 类型上不存在属性 snapshotChanges

问题描述 投票:0回答:1

我正在开发 Angular(版本 9.1.13) 我正在使用 Firestore 、Fire 版本 ("@angular/fire": "^6.1.5") 、Firebase 版本 ("firebase": "^8.10.1") 作为数据库的项目。我正在尝试使用带有

where
orderBy
limit
方法的查询从 Firestore 获取数据。这是我的代码:

const ref: CollectionReference = this.firestore.collection(this.path()).ref;
let query: Query = collectionRef
        .where(...conditions...)
        .where(...conditions...)
        .orderBy('time', 'desc')
        .limit(5);

this.subscription = query.snapshotChanges().subscribe((changes) => {}

但是我在 query.snapshotChanges 行收到错误消息 - 属性 snapshotChanges 在类型 Query 上不存在

我的问题-

  1. 如何在 AngularFirestore 中正确使用 snapshotChanges() 进行过滤和排序查询的实时更新?
  2. 升级 Firestore 是解决此问题的可行解决方案吗?
angular firebase google-cloud-firestore snapshot
1个回答
0
投票

snapshotChanges()
方法特定于AngularFire库。

您的代码似乎使用的是常规的 Firebase SDK for JavaScript,但它没有

snapshotChanges()
,而是有一个方法
onSnapshot

© www.soinside.com 2019 - 2024. All rights reserved.