0

Lets say I have an array field in a document:

entries: ["hello"]

I would like to append new elements to this array field i.e ["Yellow" ,"Blue"]

I did some research and most the techniques replace the entire record. How can I achieve this?

I'm using javascript.

4
  • 2
    what language are you using? do you have more sample code? more context would be useful. Commented Feb 9, 2018 at 4:42
  • In the most languages you can do: entries[] = "Blue"; Commented Feb 9, 2018 at 4:44
  • edited, javascript. Commented Feb 9, 2018 at 4:45
  • what context do you need? i have an array field. how do i add elements to it without overwriting the whole field? Commented Feb 9, 2018 at 4:46

1 Answer 1

2

Check out this question: How to append something to an array? .

And looks like you are developing using firebase firestore, please take a look at their documentation here.

You'll have to retrieve the document you want to edit first, append the array, then update it.

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.