删除 Firestore 中数组的索引 [英] Delete index at array in Firestore

查看:22
本文介绍了删除 Firestore 中数组的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的文档中得到了这些数据:

I got this data in my document:

我想删除索引 0.我该怎么做?这应该可以解决我认为的问题:

I want to delete index 0. How do I do this? This should do the trick I thought:

    db.collection("data").document("free").updateData(["deleteme.deletemee.0" : FieldValue.delete()]) { (errr) in
        print(errr)
    }

但是 errr 打印 nil,并且没有删除任何内容.获取文档时,我注意到使用此代码时数据有些奇怪:

But the errr prints nil, and nothing is removed. When getting the document I noticed something strange about the data when using this code:

    db.collection("data").document("free").getDocument { (doc, err) in
        guard let _doc = doc,
            doc?.exists ?? false else{ return }
        print(_doc.data())
    }

打印出来:

["deleteme": {
    deletemee =     (
        1 //this is the value for the key, but where is my key?! :(
    );
}]

我看不到钥匙,它在哪里?如何在 Firestore 的索引中删除某些内容?谢谢.

I cannot see the key, where is it? How to delete something at an index in Firestore? Thanks.

推荐答案

终于支持数组操作了.现在支持删除、添加等通过值(不是索引):

Array operations have finally been supported. Deletion, addition, etc. are supported via the value (not the index) now:

目前,目前有一些错误,如 这个 我遇到过.

At the moment, there are a few bugs at the moment though as this one I encountered.

开发博客 此处:

这篇关于删除 Firestore 中数组的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆