NodeJS - Firebase - Cannot read properties of undefined (reading 'where')

249 Views Asked by At

I have a function which should query the Firestore. It looks like this

class TournamentParticipationDataAccessService {
  
    setProperties() {
       this.tournamentParticipationRef = database.collection('/tournamentParticipation')
    }

   checkIfTournamentHasReachedParticipationNumber(tournamentObject) {    

    this.tournamentParticipationRef.where("tournamentId", "==", tournamentObject.objectID).where("round", "==", tournamentObject.currentRound)
        .get()
        .then((querySnapshot) => {
    
         // MAGIC

     }  
   ..
}

It complains about that where statement. The database variable is defined in a different file:

firebase = require('firebase');
firebaseAdmin = require('firebase-admin');
..
database = firebase.firestore(); 

My index.js file where the variables from top are defined doesn't contain any classes. Just a plain script.

0

There are 0 best solutions below