简体   繁体   English

如何使用 Koltin 从 Firestore 中的 ArrayList 中删除项目

[英]How delete Item from ArrayList in Firestore using Koltin

I want to delete one item from the animeId .我想从animeId中删除一项。 For example, if I need to remove the animeId[5] or I want to remove the item that the value is equal 5114 , how can I do that?例如,如果我需要删除animeId[5]或者我想删除值等于5114的项目,我该怎么做? I alredy learned how I remove item like the entire animeId but not just one item.我已经学会了如何删除整个animeId之类的项目,而不仅仅是一个项目。 Here's an print how the database is organized:这是数据库的组织方式的打印: 在此处输入图像描述

For updating some fields of a document, use the update() method.要更新文档的某些字段,请使用 update() 方法。

If you want to remove a specific item from an Arraylist, you can use a call to:如果您想从 Arraylist 中删除特定项目,您可以调用:

.update("arrayfield", FieldValue.arrayRemove("itemtoremove"))

For example if you have an arraylist that contains three items as “abc”, “efg”, “xyz”.例如,如果您有一个 arraylist,其中包含三个项目“abc”、“efg”和“xyz”。 And if you want to remove specific item called “efg” from an arraylist you should use a call to:如果你想从 arraylist 中删除名为“efg”的特定项目,你应该调用:

.update("arrayfield", FieldValue.arrayRemove("efg"))

Please also take a look at this Stackoverflow Link which explains clearly on how to remove specific items from the array list in the firestore using kotlin.另请查看此Stackoverflow 链接,该链接清楚地说明了如何使用 kotlin 从 firestore 的数组列表中删除特定项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 where 子句从 Firestore 中删除文档 - How to delete document from firestore using where clause 您如何使用 Dissmissable 从 itembuilder 中删除一个项目并且该项目来自 Firestore? - How do you remove an item from from itembuilder using Dissmissable and the item is from Firestore? 如何从 firestore 中删除每个集合 - How to delete every collections from firestore Java,Firestore - 在 android 工作室中使用 arraylist 的文档 ID 从 Firestore 获取多个文档 - Java, Firestore - Get multiple documents from firestore using an arraylist of document ids in android studio 如何在已经从 Firestore KOTLIN 获取 arrayList 的片段上实现 SearchView - How to implement SearchView on fragment that is already fetching arrayList from firestore KOTLIN 如何使用 Angular 5 中的批量写入从 Cloud Firestore 中删除多个文档 - How to delete multiple documents from Cloud Firestore using Batched writes in angular 5 FLUTTER:如何在cloud firestore 中使用where 子句删除多个文档? - FLUTTER: How to delete multiple documents using where clause in cloud firestore? 如何使用特定参数 flutter 从 Firestore 中删除数据? - How to delete data from Firestore with specific parameter flutter? 如何更新 Firestore 中的数组项 - How to update an array item in Firestore Flutter Firestore:无法删除广播中的项目 stream - Flutter Firestore : Unable to delete item inside the broadcast stream
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM