Go 使Firestore仅返回客户id小于1000的用户

Go 使Firestore仅返回客户id小于1000的用户,go,google-cloud-firestore,Go,Google Cloud Firestore,如何提取数据库中客户id小于8位的用户 我试着这样做: iter:=client.Collectionusers.Wherecustomer\u id,不是firestore用户,但我从中找到了一些信息 countryQuery:=城市。Wherestate,==,CA PopQue: =城市。 所以我觉得你应该试试: iter:=client.Collectionusers.Wherecustomer_id,发生这种情况的原因是您将字段设置为字符串而不是数字。我复制了用例场景,以下是我的发现:

如何提取数据库中客户id小于8位的用户

我试着这样做:


iter:=client.Collectionusers.Wherecustomer\u id,不是firestore用户,但我从中找到了一些信息

countryQuery:=城市。Wherestate,==,CA PopQue: =城市。 所以我觉得你应该试试:


iter:=client.Collectionusers.Wherecustomer_id,发生这种情况的原因是您将字段设置为字符串而不是数字。我复制了用例场景,以下是我的发现:

我的Firestore数据库:

collection: users
>> document: "auto_id"
   --customer_id: 111
>> document: "auto_id"
   --customer_id: 123
>> document: "auto_id"
   --customer_id: 4500
>> document: "auto_id"
   --customer_id: 3500

我已在Firestore中将每个客户id设置为字符串。然后,当使用Wherecustomer\u id,==,111方法时,会给我map[customer\u id:111],但当使用Wherecustomer\u id时,我认为您无法检查长度,您可能必须将长度存储为单独的字段如果customer\u id存储为整数,则在以下条件中使用整数值:Wherecustomer\u id,请将您的数据库结构添加为屏幕截图。谢谢您的建议。事实上我自己找到了那个医生并尝试了你的建议。它不会返回任何东西。我想这是因为客户id是Firestore中的字符串。如果我可以将它转换为int,它可能会工作,但我还没有找到如何做到这一点。
iter := client.Collection("users").Where("customer_id", "==", "111").Documents(ctx)
collection: users
>> document: "auto_id"
   --customer_id: 111
>> document: "auto_id"
   --customer_id: 123
>> document: "auto_id"
   --customer_id: 4500
>> document: "auto_id"
   --customer_id: 3500
 map[customer_id:111]
 map[customer_id:123]