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?