Flutter & Firebase:如何在创建文档时将 documentID 放入文档字段?
通常情况下,如果我们创建文档时没有指定documentID,firebase会为我们生成一个ID,对吧?
就我而言,我希望 firebase 为我生成 ID,然后将该 ID 放入文档字段之一。我该怎么做?
await feedbackCollection.document().setData({
'comment' : comment,
'feedback_id' : ????,
});
最佳答案
DocumentReference docRef = await feedbackCollection.document();
docRef.setData({
'comment' : comment,
'feedback_id' : docRef.id,
});
关于firebase - flutter 和 Firebase : How can I put the documentID into the document field the moment I just create the document?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64366566/