Search code examples
javascriptangulargoogle-cloud-firestoreangularfire2

You can only perform equals comparisons on NaN


I'm working with angular 6 and firestore. I have a query:

    let cadena=Number(this._tempFirebaseRepo.getCadenaFecha(1));

    //aca esta la query de Firestore
    this.dispositivoRef = this.afs.collection('Dispositivo', ref =>
         ref.where('fecha', '>', cadena)
    )
    debugger;
    this.ultimoDia = this.dispositivoRef.valueChanges(); 

On the browser console appear this error:

You can only perform equals comparisons on NaN


Solution

  • The Number() method can return NaN in certain cases. For example, Number('foo') is not a number, and returns NaN.

    You cannot check if a number is 'bigger' or 'smaller' than something that isn't a number, the question itself doesn't make sense.

    In this case, check the value of cadena. That's where your issue lies.