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

193
Vistas
Firebase: startAt() is not filtering data stored with keys as hours since epoch

My data is stored with keys as hours since epoch. I want to get only slice of the data - so for example I want to specify that I want all data starting at 453615.

So far I got this code:

  this.dbService.databaseRef.child('dev_trends/' + this.deviceUid)
  .orderByKey()
  .startAt('453615')
  .get().then(dataTrends => {
    const data = dataTrends.val();

    console.log(data);
  });

With the code above I get this results in my console:

enter image description here

My data model looks like this:

enter image description here

What should I change in my code so that I get the data from Firebase filtered?


I create the databaseRef variable inside a service with this code:

  constructor(private db: AngularFireDatabase) {
    //Set what happens when we read all devices
    this.databaseRef = db.database.ref(); //Create databaseReference
  }

Json of my data:

  {"dev_trends" : {
    "-MkMxxZXXzmKclgeGPde" : {
      "H" : {
        "453614" : "50;45",
        "453615" : "50;50",
        "453617" : "50;55",
        "453630" : "51;60"
      },
      "T" : {
        "453614" : "24;18",
        "453615" : "23;17",
        "453617" : "23;15",
        "453630" : "22;10"
      }
    }
  }}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Find out where the problem was:

  • The startAt() method was filtering data with keys H and T and not the lists of data inside those keys.
  • Solution was to restructure the data model.

New data model:

enter image description here


Additional info:

  • I am not saying my solution is ideal - but for my specific problem it will do the trick.
  • It will still require some additional work for me - so if anyone else has a better solution for this please post Your answer too :)
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