0

I'm trying:

await firebase.firestore().doc(`documents/${documentData.id}`).update({
    predictionHistory: firebase.firestore.FieldValue.arrayUnion(...[predictions])
});

where predictions is an array of:

export interface PredictionHistory {
    predictedAt: firebase.firestore.Timestamp;
    predictionText: string;
}

But I get an error:

FirebaseError: Function FieldValue.arrayUnion() called with invalid data. Nested arrays are not supported

Any idea what I'm doing wrong?

1
  • Hey Shamoon. Did you get anywhere with this? I tried helping with an answer below. Did you have a chance to check that out and try it? Commented Jun 17, 2021 at 4:01

1 Answer 1

1

I think you may be overcomplicating the call, and be looking for:

predictionHistory: firebase.firestore.FieldValue.arrayUnion(predictions)

This will add any elements from the predictions array that are not yet in the predictionHistory field.

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.