Quantcast

Parser/Interpreter for JSON queries mongodb

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Parser/Interpreter for JSON queries mongodb

chrismihaylyk
This post was updated on .
Hello!

I'm creating MongoDBBrowser that have all CRUD operations and I need a parser that translates javascript queries in MongoDB to the queries, for making selects, inserts etc. using Mongo class.
For example, I have query

db.SomeCollection.find( {$or: [ { name: { $regex: /test/i } }, { description: { $regex: /test/i } } ] } )

that is manually rewriting into
someCollection select: {
        '$or' -> {
                { 'name' -> {
                        '$regex' -> 'test' .
                        '$options' -> 'i' } asDictionary } asDictionary.
                { 'description' -> {
                        '$regex' -> 'test' .
                        '$options' -> 'i' } asDictionary } asDictionary
        }
} asDictionary

But I need to have a parser that will do it automatically.

Maybe there are already exist one? If not, how to write my own?
Please help.

Thanks a lot, Khrystyna=)
Loading...