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

255
Vistas
Javascript Firebase Firestore returning disordered data

When I run the following using the JS client sdk

import { firestore } from "../../../firebase";

export default async (userId) => {
  const userRef = firestore.collection("users").doc(userId);
  const userDoc = await userRef.get();

 
  if (!userDoc.exists) {
     throw new Error("User doesn't exist");
  }

  console.log(JSON.stringify(userDoc.data(), null, 2));

  const userData = {
    id: userDoc.id,
    ...userDoc.data(),
  };

  return userData;
};

multiple times, for the same userId, without having changed anything in the DB, I get the same data but with disordered fields:

{ // 1st fetch
   name: "a",
   age: 10,
   avatar: {
      uri: "x",
      thumbnailUri: "y"
   }
}


....


{ // 2nd fetch
   name: "a",
   avatar: {
      thumbnailUri: "y",
      uri: "x"
   },
   age: 10
}

What is the reason behind this? Is it possible to always get an ordered version?

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

0

Firestore documents contain data in a JSON format, and there is no way of guaranteeing the order of fields in a JSON object. If you need your fields ordered, you'll have to do it on the client.

Please see this post for more information

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