Dear all,
I use MongoDB as a data backend for a Java Web service that collects JSON documents and allows retrieving and aggregating them.
Since the programmers of the clients that use this web service are too lazy to learn the JSON semantics of the MongoDB aggregation framework, I have created a simple "human-friendly" language that does not add any extra functionality to the existing MongoDB's JSON format.
The first early version is here:
https://github.com/mariomac/mongoalIt basically translates a query like this:
FROM docs
MATCH obj.prop > 3
GROUP BY val1
sum(val1) AS Field1
sum(obj.prop) AS Field2
sum(obj.prop + val1) AS FieldsSum
SORT BY FieldsSum DESCENDING
Into something like this:
db.docs.aggregate([
{ "$match" : { "obj.prop" : { "$gt" : 3}}} ,
{ "$group" : { "_id" : "$val1" ,
"Field1" : { "$sum" : "$val1"} ,
"Field2" : { "$sum" : "$obj.prop"} ,
"FieldsSum" : { "$sum" : { "$add" : [ "$obj.prop" , "$val1"]}}}} ,
{ "$sort" : { "FieldsSum" : -1}}
]);
In its current status, MongoAL fulfills the requirements of my web service, but if I notice some interest from somebody to use it, I would like to continue developing it and adding some extra functionalities, such as:
- Porting it to Javascript (now it's in Java because my WS is java)
- Supporting the complete MongoDB aggregation pipeline (now only supports $match, $group and $sort operations.
- Adding an "FORMAT AS" command to format the output to, for example, XML, JSON, CSV...
Do you think this can be interesting for your applications such as, e.g. exposing the MongoDB aggregation capabilities to external clients?
Any suggestion and comment will be very appreciated :-)
Thanks for reading this!
Mario M.