Incrementing number fields is multi-step process now. In last firebase javascript api FieldValue.increment has been added, I feel its good to add that feature in angularfire2 too.
https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldValue
Incrementing will work in AngularFire today, you just need to upgrade your Firebase dependency.
How?
Is this working? I don't see this.afStore.firestore.FieldValue.increment available. Am I doing something wrong?
Y'all will have to use the JS SDK for that part
import { Component, OnInit } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import * as firebase from 'firebase/app';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
constructor(private readonly af: AngularFirestore) {}
async ngOnInit() {
await this.af.collection('test').add({
test: firebase.firestore.FieldValue.increment(1),
});
}
}
too bad I still have to import firebase
is there any way to use FieldValue.increment without using firebase import?
Most helpful comment
too bad I still have to import firebase