0

I am working with the Reql, the problem i am facing is that i need to filter the same plucked values in correct order.

After pluck and distinct() apply, value are correct but not in correct order, their order lost.

Sample Query

r.db('DB').table("heroes").orderBy('createdAt')
 .pluck({'loc':['coordinates']})
  .distinct()

Can anyone help me to modify the query, so that it return data in correct order.

Thanks for your time.

Community
  • 1
  • 1
Suhail Mumtaz Awan
  • 3,295
  • 8
  • 43
  • 77

1 Answers1

0

After looking for another workaround i posted question here (thanks to @trincot) to get work done in javascript instead to handle duplicate array of lat longs, by duplicating solution of this sample array. Getting distinct result and the order is maintained.

var array = [  
    { person: { amount: [1,1] } },
    { person: { amount: [1,1] } }, 
    { person: { amount: [2,1] } },
    { person: { amount: [1,2] } },
    { person: { amount: [1,2] } }
];

var result = [...new Map(array.map( o => [JSON.stringify(o), o])).values()];

console.log(result);

In case of anyone who might get help.Cheers.

Suhail Mumtaz Awan
  • 3,295
  • 8
  • 43
  • 77