Order By Array Size

0 votes

Hi,

I have a collection of jsons which have array and some other values. I want to order them by array.size and fetch them by paging. I use findDocsWithQueryPagingOrderBy method but cant succeed.

The collection is like;

{"users":["user001","user002","user003"],""point":100,"name":"GROUP1"}
{"users":["user004],""point":300,"name":"GROUP2"}
{"users":["user005","user006","user007","user008"],""point":200,"name":"GROUP3"}
{"users":["user005","user009"],""point":200,"name":"GROUP4"}
 
In this collection, I want to receive GROUP3 first, because it has more users than others. And then GROUP1,GROUP4 and GROUP2.

Can you assist me, please? Thanks

asked Apr 12, 2015 in App42 Cloud API-BaaS by Tufan (64 points)

1 Answer

0 votes
This can not be done implicitly and you have to modify your JSON to achieve it. Save size value in number format in your JSON and use it in order by clause, this will solve your problem.

Let me know if it helps.

Thanks

Ajay
answered Apr 13, 2015 by ajay123 (899 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...