Cloud Firestore 按Europe/Chisinau时区查询用户返回空列表
场景需求
我需要查询所有时区为Europe/Chisinau的用户,这类用户的文档结构示例如下:
'device': { 'from': '{"status":"success","country":"Moldova","countryCode":"MD","zip":"MD-3300","timezone":"Europe/Chisinau"}' }
需要说明的是,上述结构中的device.from字段为字符串类型,其取值是一段序列化后的JSON字符串,真正的时区信息就存储在这段序列化字符串内部。
问题复现
我编写了如下代码执行查询:
# 初始化Firestore客户端 from google.cloud import firestore firestore_client = firestore.Client.from_service_account_json('creds.json') ref = firestore_client.collection('databases').document('testing') # 执行范围查询匹配Europe/Chisinau ref.collection(u'users').where(u'device.from', u'>=', u'Europe/Chisinau').where(u'device.from', u'<=', u'Europe/Chisinau').get() # 实际返回结果:[]
上述代码执行后始终返回空列表。
我当前使用的Firestore开发依赖来自官方维护的GoogleCloudPlatform/python-docs-samples代码库,未修改SDK核心查询逻辑。
内容的提问来源于stack exchange,提问作者user13824551
相关产品推荐
相关产品推荐

