【发布时间】:2021-10-28 22:16:24
【问题描述】:
我写了以下代码。 但是,当我运行它时,它不起作用。 我可能无法获得文档 ID。 抱歉,如果我的代码有任何修改,请告诉我。
Future<void> deleteRoom() async {
//Put the ID of the document to be deleted in the list
List deleteRoomIdList = [];
//The ID of the document to be deleted is placed here in a for statement.
String deleteId;
FirebaseFirestore.instance
.collection('room')
.where('roomCount', whereIn: [0, null])
.get()
.then((QuerySnapshot querySnapshot) => {
querySnapshot.docs.forEach(
(doc) {
deleteRoomIdList.add(doc.id);
},
),
});
//Deleting with a for statement
for (deleteId in deleteRoomIdList) {
await FirebaseFirestore.instance
.collection('room')
.doc(deleteId)
.delete();
}
}
【问题讨论】:
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: firebase flutter dart google-cloud-firestore