我的数据库如下:
month = int(input('Please enter a month in numeric form: '))
day = int(input('Please enter a day in numeric form: '))
year = int(input('Please enter a two-digit year in numeric form: '))
if month * day == year:
print ('The date is magic!')
else:
print ('The date is not magic.')
现在,我想获取包含“ project1”和“ project2”的客户,并且这些项目是动态分配的,因此{
"customers": [
{
"field1": "value1",
"field2": "value2",
"field3": "test",
"projects": [
"project1",
"project2",
"project3",
"project4"
]
},
{
"field1": "value1",
"field2": "value2",
"field3": "value3",
"projects": [
"project1",
"project3"
]
}
]
}
在我看来似乎不是一个选择,因此我使用了whereEqualTo
,如下所示:
whereArrayContains
效果很好,但是随后我需要搜索多个项目,所以我继续这样说:
Query query = db.collection("customers");
query = query.whereEqualTo("field3", "test");
query.whereArrayContains("projects", "project1");
此处应用程序崩溃,说明:
无效的查询。查询仅支持具有单个数组包含
所以这就是我现在遇到的问题,我知道我们不能放多个Query query = db.collection("customers");
query = query.whereEqualTo("field3", "test");
for (int i = 0; i < selectedProjects.size(); i++) {
//i get a crash here:
query = query.whereArrayContains("projects", selectedProjects.get(i).getText());
}
,那么要实现我刚刚解释的目标,我有什么选择?
为什么我们这里不能像sqlite这样简单的whereArrayContains
查询?