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

查看:73
本文介绍了在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天全站免登陆