【发布时间】:2018-11-17 20:22:41
【问题描述】:
我想在创建时在 firestore 数据库中创建一个整数值。但是,我传递的每个变量都会变成一个字符串。
这就是我所拥有的:
next_group_id = self.GetNextGroupId() #returns int value
try:
# get the document
doc_ref = self._db.collection(GROUPS).document(next_group_id)
# create a new document
# this gets created as a string in firestore
doc_ref.set({
u'Group Id': next_group_id,
})
print("Created Group '{}'.".format(group._group_name))
except:
print("Possible firestore error has accord - unable to create group")
【问题讨论】:
-
如果您对值进行硬编码,它设置的数字是否正确? IE。
doc_ref.set({ u'Group Id': 12, })。如果是这样,至少很明显问题出在客户端/Python 端。 -
我收到此错误路径元素必须是字符串。收到 102,这是一个
. -
嗯……这听起来很奇怪。我不确定为什么会这样,所以希望其他人注意到。
标签: python-3.x firebase google-cloud-firestore firebase-admin