【发布时间】:2019-10-30 12:22:13
【问题描述】:
我正在尝试为 firebase 集合引用创建 where 子句:
this.allItineraries = firebase
.firestore()
.collection(`itinerary`);
这里是 where 子句:
return this.allItineraries.where('userId', '===', this.userId);
但是程序不会编译并给出以下错误:
[ng] src/app/services/data.service.ts(45,55) 中的错误:错误 TS2345: '"==="' 类型的参数不能分配给类型参数 'WhereFil
where 子句看起来与我在 firebase 示例中看到的相同。
【问题讨论】:
-
它是否适用于“==”?我还没有使用角火,但我看到文档支持“==”。 github.com/angular/angularfire2/blob/master/docs/firestore/…
-
firebase.google.com/docs/firestore/query-data/queries: 比较可以是, >=, or array_contains
-
当我将其更改为 '==' 时,我得到以下信息: src/app/services/data.service.ts(49,7) 中的错误:错误 TS2322:类型 'Query' 不是可分配给类型“CollectionReference”。 [ng] 类型“查询”中缺少属性“id”。
-
我也试过这个: const ref = this.allItineraries('id'); return ref.where('userId', '==', this.userId 并得到以下错误; src/app/services/data.service.ts(49,19) 中的错误:错误 TS2349:无法调用其表达式类型缺少调用签名。类型“CollectionReference”没有兼容的调用签名。
-
.where() 返回一个查询,而不是 CollectionReference。
标签: angular typescript firebase google-cloud-firestore ionic4