3

This is my .ts file

import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';

@Component({
  selector: 'app-candidate-reg-success',
  templateUrl: './candidate-reg-success.component.html',
  styleUrls: ['./candidate-reg-success.component.css']
})
export class CandidateRegSuccessComponent implements OnInit {

  constructor() { 
    debugger;
    const rootRef=firebase.database.ref();
    const mail=rootRef.child('candidates_list').orderByChild('email').equalTo('pranavkeke@gmail.com');
    console.log(mail);

  }

  ngOnInit() {
  }

}

I am trying to query the user from candidates_list table which has the email address pranavkeke@gmail.com.

But I am unable to console it. It shows a error like

Property 'ref' does not exist on type 'typeof database'.

Any solution to query angular firebase database?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
pranavyoyo
  • 75
  • 1
  • 6

1 Answers1

2

you need to inject the AngularFirebaseData in constructor and change the code and try again

import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable,   
   FirebaseObjectObservable } from 'angularfire2/database';

@Component({
  selector: 'app-candidate-reg-success',
 templateUrl: './candidate-reg-success.component.html',
 styleUrls: ['./candidate-reg-success.component.css']
})
  export class CandidateRegSuccessComponent implements OnInit {

  constructor(public db: AngularFireDatabase) { 
    debugger;
    db.list('/candidates_list', ref => ref.orderByChild('email').equalTo('pranavkeke@gmail.com'));
}   
 ngOnInit() {
    }}
Chellappan வ
  • 23,645
  • 3
  • 29
  • 60
  • Hi @Chellappan வ this works perfectly for me can you give one example how can I query having multiple parameters like email name etc etc? – kushal Baldev Jul 27 '20 at 10:14
  • Can you check this:https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md – Chellappan வ Jul 27 '20 at 15:10
  • Yes I tried with fire store but was upset by getting this error I already have a question for this error on stack overflow but this question is not answered yet the error is This likely means that the library (@angular/fire/firestore) which declares AngularFirestore has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy. – kushal Baldev Jul 27 '20 at 15:16
  • It seems it's supported by angular 9+ https://github.com/angular/angularfire/tree/6.0.2 – Chellappan வ Jul 27 '20 at 15:57
  • Yes thats the main problem do you know about the querybase? I was trying a hand over it I just ran the npm command and installed it but I dont know how to import and use this it would be great if you can provide some guidence here https://stackoverflow.com/questions/63113829/how-to-import-querybase-in-angular – kushal Baldev Jul 27 '20 at 16:04
  • In documentation also they have provided example have you check this:https://github.com/angular/angularfire/blob/master/docs/firestore/querying-collections.md#example-app – Chellappan வ Jul 27 '20 at 16:07
  • Yes but thats about firestore which is not working currently as I showed you error so another option that I had is the Querybase thats developed by David East so was trying out that .Its just like an addon on firebase – kushal Baldev Jul 27 '20 at 16:13
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/218702/discussion-between-chellappan--and-kushal-baldev). – Chellappan வ Jul 27 '20 at 16:18