Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
Using equalTo() function in Firebase Database JavaScript v9

I am trying to use the equalTo function in the Firebase Database JavaScript v9 SDK. It's not very well documented like V8 is so can't figure out how to do what I want to do.

I want to filter results by the type field. My parent field is request-log with child elements like below.

{"backtrace":false,"message":false,"organisationID":"Empty","postData":false,"referrer":"Empty","remoteIP":"0.0.0.0","requestMethod":"POST","time":1630129562,"type":"Error","url":"Empty","user":{"email":"Empty","firstName":"George","id":37,"lastName":"Bates"},"userAgent":"Empty"}

I am trying the following, but not getting any results when loaded:

const readNewLogEntries = query(child(ref(db), 'request-log'), equalTo('Error', 'type'));

I have also tried this, as the reference docs say for the 2nd argument in the equalTo() function

This argument is only allowed if ordering by child, value, or priority.

But this isn't working either

const readNewLogEntries = query(child(ref(db), 'request-log'), orderByChild('type'), equalTo('Request', 'type'));

EDIT: Screenshot of DB

Screenshot of DB

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Remove the second parameter from equalTo().

The optional key argument can be used to further limit the range of the query. If it is specified, then children that have exactly the specified value must also have exactly the specified key as their key name. This can be used to filter result sets with many matches for the same value.

const getData = async () => {
  const readNewLogEntries = await get(
    query(ref(db, "request-log"), orderByChild("type"), equalTo("Request"))
    // Filters where "type" is equal to "Request". Single arg here ⬆ 
  );
  console.log(readNewLogEntries.val())
  return readNewLogEntries.val();
};

You can read more about the parameters in the documentation

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda