我有以下文件:
{
"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)
但这取决于活动值,这不适用于所有情况。
我注意到当我将 cdk 虚拟滚动的 itemSize 设置为较低的值时,页面的加载时间几乎是两倍。
<cdk-virtual-scroll-viewport [itemSize]="45"和<cdk-virtual-scroll-viewport [itemSize]="20"(一个有 2k 行的表)之间有很大的不同。
我的问题是为什么页面的加载从 2 秒到将近 5 秒?怎么会有这么大的不同?