David Díaz
David Díaz

Reputation: 119

How to add a new reference to a firestore object

What I'm trying to do is to add a new reference to this object:

Firestore

Just insert a new element inside "citas". This is what I have so far.

database.collection('NegociosDev').doc('Peluquerías')
    .collection('Negocios').doc('PR01').collection('empleados').where('Nombre', '==','Ale')...

I guess I shouldn't use "add()" as it is used to add a new document right? Any ideas?

Upvotes: 0

Views: 153

Answers (1)

Olivier Lépine
Olivier Lépine

Reputation: 668

Indeed, you should update your document this way:

database.collection('NegociosDev').doc('Peluquerías').update({
   citas: firebase.firestore.FieldValue.arrayUnion("new value")
})

Upvotes: 2

Related Questions