Acording to the mongoDB documentation (link) if you want to store geospatial information in a document field, you have two options, an array or an embedded document, and the order should be always longitude, latitude.
If I want to use an embedded document, how can I ensure the field's order?
Or must the fields in the embedded document have a specific name?
with an embedded document, regardless of the name of the field in the embedded document, the first field should contain the longitude value and the second field should contain the latitude value. For example:
db.zips2.insert( { _id: 1, city: "b", loc: { x: -73.974, y: 40.764 } } )
db.zips2.insert( { _id: 2, city: "b", loc: { x: -73.981, y: 40.768 } } )
Here the x field would be the longitude; and the y field would be the latitude.
Regards