Let collection be
[
{area:'121',name:'r',age:'1'},
{area:'122',name:'rt',age:'21'},
{area:'121',name:'r',age:'1'}
]
I want query that will return
[
{area:'121',name:'r',age:'1'},
{area:'122',name:'rt',age:'21'}
]
i.e entry that have unique area value. I tried to search and use distinct
collections.collection('collection')
.distinct('area', (err, sus) => {
if (err) {
console.log(err)
resp.status(501).send()
} else {
console.log(sus)
resp.send(sus)
}
})
but the output is
["121","122"]
This is giving me only distinct values but i want the full entry. How to get that?