【发布时间】:2021-06-07 22:15:02
【问题描述】:
我想从 Firestore 的数组中删除一个特定的字段(它是用户 ID)。
我试试:
override fun unlikePost(postId: String) {
FirebaseFirestore.getInstance().collection(postCollection)
.document(postId).update("likeList", FieldValue.arrayRemove(FirebaseAuth.getInstance().uid))
}
但是当我这样做时,我在 Firestore 中的likeLIst 更改为:
[]
为什么 distinctPost 不删除特定字段而是清除整个数组并更改为 []?
【问题讨论】:
-
字段中的值是否比屏幕截图中显示的值多?
-
是的,有。当我调用我的函数时,它会从数组列表中删除所有字段。
标签: android firebase kotlin google-cloud-firestore