I use MongoDB as application data storage. To sort retrieved documents, I write the following code (in perl):
$db->user->find({})->sort({ username => -1 })
where { username => -1 } means that the result of the query should be sorted by attribute username in descending order.
On the client-side I use DojoX DataGrid as main element of user management interface. After clicking the column header, DataGrid sends a GET request like:
/api/user/?sort(-username)
The question is: how can I change that GET query to look like:
/api/user/?sort=&username=-1
I’d be happy to do that because my server-side framework Mojolicious offers tools for parsing key-value query strings, not the strings looking like some kind of function call.
Dojo uses RQL which looks like the Mongo Query Language. They both use JSON and are both designed for document oriented databases. You can read more about here RQL at this Sitepen article.
Since RQL is so close to MQL, It might be easier to create an adaptor on the server side than to modify Dojo’s behaviour.