如何在子集合中创建新文档时获取文档中的字段名称

问题描述 投票:0回答:0

我做了一个使用 firebase 作为数据库扫描人脸的项目,通过在硬件中设置它,如果扫描人脸然后名字等于这个人,它会将数据发送到子集合。现在在数据库中它的排序是这样的集合>文档>子集合>文档>子集合>文档(创建)我想在创建文档时获得如下图所示的名称code

if name == classNames[matchIndex]:
            doc_ref = db.collection(u'teacher').document(u'AllUser').collection(u'profile').document(name).collection(u'time').document()
            my_data = {"timeStamp": SERVER_TIMESTAMP}
            doc_ref.set(my_data)

或者如何获取对文档的引用然后将文档中的字段名称获取到子集合中的新文档

if name == classNames[matchIndex]:
            doc_ref = db.collection(u'teacher').document(u'AllUser').collection(u'profile').document(name).collection(u'time').document()
            my_data = ({"timeStamp": SERVER_TIMESTAMP,
               "name":... #field name in document
                })
            doc_ref.set(my_data)
python google-cloud-firestore raspberry-pi3
© www.soinside.com 2019 - 2024. All rights reserved.