【发布时间】:2021-04-04 19:30:24
【问题描述】:
有什么方法可以在 Firestore 中创建一个新文档并以变量命名?
我尝试修改here提供的示例,但无济于事。
这是我尝试的:
import time
#declare unix variable
unix = int(time.time())
#gcp boilerplate dictionary
data = {
'name': 'Los Angeles',
'state': 'CA',
'country': 'USA'
}
#create new doc under collection with fields form dictionary
db.collection('cities').document(unix).set(data)
【问题讨论】:
-
你分享的代码有什么问题?
-
当我尝试以我的“unix”变量命名时,没有创建新文档。似乎文档名称只能硬编码。
标签: python google-cloud-firestore