[英]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.