These are chat archives for angular/material

May 2018
Nico Mee
May 07 2018 10:29
Speaking of firebase & angular I'm banging my head against the wall trying to do something pretty simple in firestore, using this as a base. I have a /users collection and each doc has a balance attribute. When a new item is added/button pressed I want the balance to decrease by one. Im new to angular though and I've managed to confuse myself, where exactly do I want to put my updateBalance method? Here's what my firestore structure looks like, really simple stuff..
May 07 2018 20:22

@nicoandmee You are going to want to update the field on the appropriate document. Something like:

userRef.update({balance: currentBalance - 1});

You will need to instantiate currentBalance, but that's the basic concept. The button handler function will need to be in your component class, but the component could, in turn, call a service that is injected into the component. See: Documents in AngularFirestore