There is the library jLinq , I already used this library and it answered me very well, I did not use the part of GROUP BY
(there is not in the documentation but if you look at the source there is the group () method), I have always used the filters and sort part of the library.
But checking here for part of group by
also works correctly, even though we are not in the developer site demos, I've done some examples to illustrate how it works:
// filtro nomes de paises que iniciam "B" na lista
var result = jlinq.from(array)
.starts("country.nome", "B")
.select();
And an example of GROUP BY
:
// Agrupa array por nome do pais
var resultGroup = jlinq.from(array)
.group("country.nome");
Follow this online example that best illustrates how it works.
Edit
According to @Thiago's comment, the question of how to specify the return fields (or format) in a query with the library jLinq . So I've also created an example for this situation:
// você consegue fazer um select no que você quer retornar
var result = jlinq.from(array)
.starts("country.nome", "B")
// o 'rec' é um alias da consulta
.select(function(rec) {
// returnando um objeto no formato que você desejar
return {
id:rec.id,
};
});
Or, even if you doubt @Thiago, you can even simplify and return only an Array of ids:
var result = jlinq.from(array)
.starts("country.nome", "B")
.select(function(rec) {
return rec.id
});
Follow the online example of this new implementation.