While hovering on collection I am getting this error
Property 'collection' does not exist on type 'AngularFireDatabase'
this.db.collection("cities").doc("LA").set({
name: "Los Angeles",
state: "CA",
country: "USA"
})
.then(function() {
console.log("Document successfully written!");
})
.catch(function(error) {
console.error("Error writing document: ", error);
});
I have already imported this
import { AngularFireDatabase } from "@angular/fire/database";
Fine , actually firestore is not available in firebase package we have to import it again .
//Use one which works fine for you
import * as firebase from "firebase/app";
import * as firebase from 'firebase';
//Now import this
import 'firebase/firestore';
For Angular Fire database we have to create an object of Angular Fire Database
var db = firebase.firestore();
If you are using Real Time Database then you have to do injection in constructor same way I was doing in above mentioned snap . So actually I was doing it in wrong way
This github post was helpful