我在Firebase的Cloud Firestore中具有此数据库结构:
@Repository
public interface PersonRepository extends JpaRepository<Person, Long>, QueryByExampleExecutor<Person> {
}
我想在Swift 4中检索所有拥有ID = 2的俱乐部。
此代码对我不起作用:
{
"Club": [
{
"name": "club one",
"address": "via Roma",
"owners": [
{
"name": "Mario Rossi",
"id": "1"
},
{
"name": "Giorgio Verdi",
"id": "2",
}
]
},
{
"name": "club two",
"address": "via milano",
"owners": [
{
"name": "Giorgio Verdi",
"id": "2"
}
]
}
]
}
这是真正的数据库结构:
答案 0 :(得分:1)
无法在您当前的结构中进行查询。您需要保留所有者ID的单独数组以允许此查询:
"owner-ids": [ "1", "2" ],
"owners": [
{
"name": "Mario Rossi",
"id": "1"
},
{
"name": "Giorgio Verdi",
"id": "2",
}
]
现在您可以在array-contains
数组上使用owner-ids
。