Add element to Firestore array

Péter Kovács

Currently, I have an empty array in Firestore dashboard. And I'm trying to add some item to it. I've followed this, but no result. I don't want to sore and rewrite this element.

My gradle contains:

implementation 'com.google.firebase:firebase-firestore:17.0.4'

and my code:

import com.google.firebase.firestore.FieldValue

...

val documentReference = firestore.collection("events")
                .document(event.firebaseUserUid + "-" + event.title)
    documentReference
                .update("participants", (FieldValue.arrayUnion(FirebaseAuth.getInstance().currentUser!!.uid)) )

But FieldValue.arrayUnion doesn't exists.

Péter Kovács

Newest version of firestore now supports it:

 implementation 'com.google.firebase:firebase-firestore:17.1.0'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related