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
331 views
in Technique[技术] by (71.8m points)

javascript - How to remove an array item from a nested document in firebase?

I'm working on a Vue,firebase app and I'm saving the userevents in a firebase collection, I update this userevents array when a user schedule an event and want to delete it when the user cancels or remove it,

users(collection) -
 test123(document) -
      "id" . --fields
      "username" . --fields
      "userevents" . --array
         [0]
            "eventid"
            "date"
            "desc"
            "status"
         [1]
            "eventid"
            "date"
            "desc"
            "status"

From UI, if the user cancels an event, I will have the eventid and want to delete it from the userevents array. I tried removing the item from the array using below code, but it is deleting all the items from the userevents,

userRef.update({
    eventid: firebase.firestore.FieldValue.delete()
});

Is there a way to achieve this in firebase?

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

...