英文:
How can i populate my array of passengerIDs in cloud firestore from my flutter app
问题
我创建了一个乘客ID列表,但现在无法访问它们,以便在每次用户被接受乘坐时添加/更新乘客ID。
这是我的代码:
FirebaseFirestore.instance
.collection("tripsStatus")
.doc("${request.tripID}/passengerIDs")
.update({"${int.parse(seat) - int.parse(data)}": request.userID});
我尝试在用户请求加入乘坐时每次更新列表,但它不起作用,还给我一个错误:
java.lang.IllegalArgumentException: 无效的文档引用。文档引用必须具有偶数段,但tripsStatus/1686505092901977/passengerIDs有3段。
英文:
I created a list of passengerIDs but now I am not able to access them in order to add/update a passengerIDs everytime a user is accepted to a ride
Here is my code
FirebaseFirestore.instance
.collection("tripsStatus")
.doc("${request.tripID}/passengerIDs")
.update({"${int.parse(seat) - int.parse(data)}": request.userID});
I tried to update everytime the list when a user requested to join the ride but it's not working it also gives me the error
> java.lang.IllegalArgumentException: Invalid document reference. Document references must have an even number of segments, but tripsStatus/1686505092901977/passengerIDs has 3
答案1
得分: 1
你的错误意味着你没有更新一个文档,你需要提供你想要编辑/更新的文档ID。
FirebaseFirestore.instance
.collection("tripsStatus")
.doc("${request.tripID}/passengerIDs/${myDocumentID}") // 在这里添加你的文档ID
.update({"${int.parse(seat) - int.parse(data)}": request.userID});
英文:
Your error means that you're not updating a document, you need to provide the documentID you want to edit/update.
FirebaseFirestore.instance
.collection("tripsStatus")
.doc("${request.tripID}/passengerIDs/${myDocumentID}") // you should add your document ID here
.update({"${int.parse(seat) - int.parse(data)}": request.userID});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论