Firestore查询Android

时间:2018-01-09 14:11:18

标签: firebase google-cloud-firestore

我在firestore中有订单集合,其中包含状态字段(String),状态字段包含那些字符串(Pending,Cooking,Cooked,Shipped,Delivered),我想查询只获取那些具有状态的文档(Pending,Cooking) ,熟了??

1 个答案:

答案 0 :(得分:0)

没有Firestore等效的SQL SELECT * FROM Collection WHERE status IN (Pending, Cooking, Cooked)。 Firestore最接近的是允许范围查询,如Tim shows here。但这只有在值(Pending, Cooking, Cooked)在范围内连续时才有效。如果他们不这样做,您将不得不执行多个查询。

由于这些值听起来像是一个过程中的步骤,因此您可以考虑在前面添加一个"步骤编号":1_Pending, 2_Cooking, 3_Cooked。通过这些,查询一系列步骤变得更加容易。或者,您也可以添加其他stepNumber媒体资源,但您必须将其与步骤名称保持同步。