That's so cool plugin. Thank you very very much! But I'm a bit confused how to transform that tree into needed code f.e. into someCollection select: { '$or' -> { { 'name' -> { '$regex' -> 'test' . '$options' -> 'i' } asDictionary } asDictionary. { 'description' -> { '$regex' -> 'test' . '$options' -> 'i' } asDictionary } asDictionary } } asDictionary Could you help me, please? 2017-04-16 21:41 GMT+03:00 Tudor Girba <tudor@tudorgirba.com>:
Hi,
Here is how to load it in Pharo 6: Metacello new smalltalkhubUser: 'JohnBrant' project: 'SmaCC'; configuration: 'SmaCC'; version: #'development'; load
Then you can do: JSParser parse: 'db.SomeCollection.find( {$or: [ { name: { $regex: /test/i } }, {description: { $regex: /test/i } } ] } )â
And you get the AST that you can play with (and transform into what you want):
Cheers, Doru
On Apr 16, 2017, at 8:06 PM, Ð¥ÑиÑÑина ÐÐ¸Ñ Ð°Ð¹Ð»Ñк <chrismihaylyk@gmail.com> wrote:
Thank you very much! But could you help me, please, to setup SmaCC into my Pharo?
Your's faithfully, Khrystyna Mykhailiuk
2017-04-16 20:57 GMT+03:00 Tudor Girba <tudor@tudorgirba.com>: Hi,
SmaCC ships with a JS parser. Please take a look at it.
Cheers, Doru
On Apr 16, 2017, at 3:42 PM, chrismihaylyk <chrismihaylyk@gmail.com> wrote:
Hello, friends!
I'm creating MongoDBBrowser that have all CRUD operations and I need a parser that translates javascript queries to MongoDB into the queries (for making selects, inserts etc.) using MongoQuery 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=)
-- View this message in context: http://forum.world. st/Parser-for-javascript-mongodb-json-notation-selects-tp4942299.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
-- www.tudorgirba.com www.feenk.com
"Reasonable is what we are accustomed with."
-- www.tudorgirba.com www.feenk.com
"Every thing should have the right to be different."