angularfire: angularfire2: upgrade: Property 'database' does not exist on type 'AngularFireDatabase'
Version info
Angular: angular/cli: ^1.4.2
Firebase: ^4.3.1
AngularFire: ^4.0.0-rc.2
How to reproduce these conditions
Steps to set up and reproduce
After upgrading my packages, the line: this.db.database.ref
throws the error: Property ‘database’ does not exist on type ‘AngularFireDatabase’.
Have looked at https://github.com/angular/angularfire2/blob/master/docs/version-4-upgrade.md but when I change the line to this.db.ref
it’s also not valid as: Property ‘ref’ does not exist on type ‘AngularFireDatabase’.
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase } from 'angularfire2/database';
@Injectable()
export class AuthService {
constructor(
private db: AngularFireDatabase,
private dbAuth: AngularFireAuth,
) {}
getUser(email) {
return this.db.database.ref(keys.database.tempUser)
.orderByChild('email')
.equalTo(email)
.limitToFirst(1)
.once('child_added', (data) => {
this.setLocalData(keys.localStorage.userIdTemp, data.key);
});
}
}
Debug output
Errors in the JavaScript console Property ‘database’ does not exist on type ‘AngularFireDatabase’.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (5 by maintainers)
I’m just starting on AngularFireDatabase and I was stumped that a working Ionic code from 3 months back no longer able to compile properly, because of the missing “database” from AngularFireDatabase class. Since I don’t know the details of how AFDB works I just let the typescript editor guide me down the defined types, and it suggests this line
should be replaced with
Can I ask the experts here if this is the correct changes, to use v4?
@larssn That’s a valid point, but please change
//
to#
in your examplerm …
command. Someone may copy-paste that to a terminal as such, without noticing the difference.The docs here are up to date https://github.com/angular/angularfire2/blob/master/docs/2-retrieving-data-as-objects.md https://github.com/angular/angularfire2/blob/master/docs/3-retrieving-data-as-lists.md
https://stackblitz.com/edit/angular-template-firebase-kjiyoc?file=app/app.module.ts yup still works fine