Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
758 views
in Technique[技术] by (71.8m points)

firebase - Delete index at array in Firestore

I got this data in my document:

enter image description here

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)
    }

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())
    }

This prints out:

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...