I have a seeds.js file that contains data like this:
var newBus = new Bus({
am: {
route: [
{
coords: {lat: 35.645329, lng: -84.068154},
address: "5408 Hutton Ridge Rd"
}
}
}
and when I call
newBus.save(function(err, data) {
if (err) throw err;
else console.log(data);
});
it stores it as something like this:
"am" : {
"route" : [
{
"address" : "5408 Hutton Ridge Rd",
"coords" : {
"lng" : -84.068154,
"lat" : 35.645329
}
}
]
}
I just noticed that it changed the order of lat, lng
to lng, lat
. I wouldn't think it would matter, but when I was doing an update to the seed data, the update only worked when I found the array that matched a specific lng, lat
. It didn't work when I tried to find a match with lat, lng
.
So why does MongoDB/Mongoose reorder the data?