【发布时间】:2019-02-16 13:43:15
【问题描述】:
我正在尝试使用 python 将 firestore 上的新文档的文档 ID 添加到对象本身中,但是在添加时它会缩短字符串并且实际上并没有添加相同的 ID。
我已经打印了 ID,它说应该是一样的。虽然在 Firestore 中有所不同。
doc_ref = db.collection(u'prime_location').document()
print('ID: ', doc_ref.id)
docId = doc_ref.id
# set object and push to firebase
doc_ref.set({
u'property_id': docId,
u'property_address': address,
u'number_of_beds': number_beds,
u'number_of_baths': number_baths,
u'property_rent': property_price,
u'post_code': postcode,
u'property_photo': property_image,
})
这方面的一个例子是文档的 id 是:'aMqwOsjDbOuQmi8PZmot' 但 'property_id' 的值是:'YU1xd09zak...' 有人知道为什么会发生这种行为吗?
【问题讨论】:
标签: python firebase google-cloud-firestore