小编Swo*_*oox的帖子

对象上的 Angular firestore array_contains

我有以下文件:

{
    "ID" : "01",
    "Name" : "A1",
    "players" : [ {
        "active" : false,
        "name" : "dissident"
      }, {
        "active" : false,
        "name" : "ink"
      }
    ]
}
Run Code Online (Sandbox Code Playgroud)

用 JSON 写下来,这样更容易理解。现在我想对 firestore 做的是查询玩家 [*].name。我已经看到了使用“array_contains”的新选项。

但是我已经看到所有示例都使用字符串数组而不是对象数组。是否可以查询玩家[*].name?

这是我尝试过的:

this.afs.collection('Locations', ref => ref.where('players.name', 'array-contains', _name))
Run Code Online (Sandbox Code Playgroud)

基于@camden_kid 反应我建立:

this.locationsCollection = this.afs.collection('Locations', ref => ref.where('players', 'array-contains', {active : false, name : _name}) );
if(this.locationsCollection === undefined){
    this.locationsCollection = this.afs.collection('Locations', ref => ref.where('players', 'array-contains', {active : true, name : _name}) );
}
Run Code Online (Sandbox Code Playgroud)

但这取决于活动值,这不适用于所有情况。

firebase angular google-cloud-firestore

8
推荐指数
1
解决办法
6927
查看次数

cdk 虚拟滚动的项目大小

我注意到当我将 cdk 虚拟滚动的 itemSize 设置为较低的值时,页面的加载时间几乎是两倍。

<cdk-virtual-scroll-viewport [itemSize]="45"<cdk-virtual-scroll-viewport [itemSize]="20"(一个有 2k 行的表)之间有很大的不同。

我的问题是为什么页面的加载从 2 秒到将近 5 秒?怎么会有这么大的不同?

angular angular-cdk angular-cdk-virtual-scroll

2
推荐指数
1
解决办法
5294
查看次数