Mohammed
Mohammed

Reputation: 1504

Getting "Type 'FieldValue' has no member 'arrayUnion'" when adding element to Firestore array

When I use this code in Xcode:

let washingtonRef = db.collection("cities").document("DC")

// Atomically add a new region to the "regions" array field.
washingtonRef.updateData([
    "regions": FieldValue.arrayUnion(["greater_virginia"])
])

// Atomically remove a region from the "regions" array field.
washingtonRef.updateData([
    "regions": FieldValue.arrayRemove(["east_coast"])
])

which is an example in Firebase Website, I get the following error:

Type 'FieldValue' has no member 'arrayUnion'

any solution to this issue ?

Upvotes: 0

Views: 755

Answers (1)

Renaud Tarnec
Renaud Tarnec

Reputation: 83093

This is probably because you have an "old" version of the iOS SDK. The arrayUnion feature has been implemented in Version 5.5.0, dated August 2, 2018.

See https://firebase.google.com/support/release-notes/ios for more detail.

Upvotes: 2

Related Questions