Here is my document structure:
{
"name": "object name",
"details": "object details",
"images": [{
"size": "large",
"url": "http://domain.com/large.png"
}, {
"size": "medium",
"url": "http://domain.com/medium.png"
}, {
"size": "small",
"url": "http://domain.com/small.png"
}]
}
Some documents only have the "large" images, some of them have all, some of them only have the "medium" image. What I want to do is, to get the url of the last element of the array.
Here is what I tried:
.find({},{"images.url":1})
Returns all url's. I tried using $slice as well, without any success (parameter errors).
Please note that I am trying to get the "url of the last element" not the "last element"
Looking for a solution.