0

i have firebase database with something like that enter image description here

and I want to delete elements starting with "12-07-20210EN5443..." i have no idea how to do that in firebase, and i spend hours on searching. i tried with that

await db.collection('Hotels')
    .doc(hotelName)
    .update({
        [date]: admin.firestore.FieldValue.arrayRemove(fieldName+"%")
    })
1
  • Where are you getting fieldName? Is it a string? Commented Jul 12, 2021 at 22:47

1 Answer 1

1

There is no single operation that allows you to delete items from an array based on a prefix. The arrayRemove operation looks for an exact, complete match.

So you will need to do this in multiple steps:

  1. Read the matching documents.
  2. Modify their array in your application code.
  3. Write back the modified array.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.