This is an example of my MongoDB object:
{
"_id": ObjectId("asdklfjasdlkfjal"),
"geometry": {
"type": "Point",
"coordinates": [
-26.62375,
152.86114
]
}
},
{
"_id": ObjectId("asdklfjasdlkfjal2"),
"geometry": {
"type": "Point",
"coordinates": [
-28.62375,
123.86114
]
}
}
Although I've consulted the documentation, I couldn't find a way to query only the first element of the array.
I attempted this line in MongoHub
: {"geometry.coordinates": {$and: [{$lt: -30, $gt: 151}, {$lt: -35, $gt: 151}]} but received an error message saying "invalid operator: $and".
For instance, I wish to retrieve the objects with a value greater than -27 as the first element in the array. This means only the first example object should be retrieved regardless of the second element's value in the array (or vice versa).
I also came across this similar question from 3 years ago and I'm wondering if there have been improvements or better solutions since then.
Thank you for taking the time to consider my question.