Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-09 Thread Stéphane Ducasse
Yes but I would like to take the opportunity to have literal object syntax. Stef > and that is one reason why a special syntax for dictionaries would be welcome > :) > > On Jul 9, 2013, at 11:42 AM, Bernat Romagosa > wrote: > >> Just in case someone runs into the same problem, the $or quer

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-09 Thread Esteban Lorenzano
and that is one reason why a special syntax for dictionaries would be welcome :) On Jul 9, 2013, at 11:42 AM, Bernat Romagosa wrote: > Just in case someone runs into the same problem, the $or query should be > written as follows: > > > User selectMany: > { > '$or' ->

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-09 Thread Bernat Romagosa
Just in case someone runs into the same problem, the $or query should be written as follows: User selectMany: { '$or' -> (Array with: { 'profile.firstName' -> { '$regex' -> '^.*na.*'. '$options' -> 'i' } *asDictionary *} *asDictionary* with: { 'profile.surname' -> { '$regex' -> '^.*ve.*'. '$opti

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Stéphane Ducasse
estebanS could you do me one favor: build a kind of list of questions and answers so that I can add that to the voyage chapter? Else I will do it but … Stef On Jul 8, 2013, at 2:38 PM, Esteban A. Maringolo wrote: > But, as far as I know, Mongo will create an _id key with an Mongo OI

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban Lorenzano
no, don't do it regular _id are taken as usual. __id fields are references to another collection documents inside one document (something that mongo does not have by itself). And I like like that :) Esteban On Jul 8, 2013, at 2:38 PM, Esteban A. Maringolo wrote: > But, as far as I know, M

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban A. Maringolo
But, as far as I know, Mongo will create an _id key with an Mongo OID for every document that doesn't have one. You can use _id without having to use an OID, you can use plain strings or integers. So I guess it is safe to use _id. I'll change it in my tests and then let you know. :) Esteban A. Ma

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban Lorenzano
Because _id is internally used by mongo and I didn't wanted to risk any collision :) On Jul 8, 2013, at 2:26 PM, "Esteban A. Maringolo" wrote: > Esteban, > > Why do you use __id: (double underscore) instead of the _id (single > underscore) key? > > Regards, > Esteban A. Maringolo > > > 2013

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban A. Maringolo
Esteban, Why do you use __id: (double underscore) instead of the _id (single underscore) key? Regards, Esteban A. Maringolo 2013/7/8 Esteban Lorenzano : > Hi again, > > sadly, there is no direct support for referenced queries yet. > > however, you can workaround the problem by doing: > > > { >

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban Lorenzano
your query is almost fine: the unique problem is with the argument for the $or expression, which should not be another dictionary but a collection: { '$or' -> (Array with: 'profile.firstName' -> { '$regex' -> '^.*na.*'. '$options' -> 'i'} asDic

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Bernat Romagosa
Thanks! The reference thing is exactly what I needed :) However, I'm not managing very well with the $or query... how would one add a regex in there? I've tried: User selectMany: { '$or' -> { 'profile.firstName' -> { '$regex' -> '^.*na.*'. '$options' -> 'i'} asDictionary. 'profile.surname' ->

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban Lorenzano
Hi again, sadly, there is no direct support for referenced queries yet. however, you can workaround the problem by doing: { 'referenceField.__id' -> (VORepository current keyOf: referenceObject) } asDictionary. or with MongoQueries: [ :each | (each at: 'referenceField.__id') = (

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Esteban Lorenzano
Hi, something like this: { '$or'-> { { $field1 -> value1 } asDictionary. "expression 1" { $field2 -> value2 } asDictionary. "expression 2" ... { $fieldN -> valueN } asDictionary. "expression N" } } asDictionary chee

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Bernat Romagosa
Also, how does one query a referenced object? MyClass selectMany: { 'project.name' -> 'Test' } asDictionary. "<-- Works only if project is an embedded object, but it doesn't if it's a reference." 2013/7/8 Bernat Romagosa > Sorry for being lazy, but how does one use logical operators in diction

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-08 Thread Bernat Romagosa
Sorry for being lazy, but how does one use logical operators in dictionary queries? I'm trying something like: (User selectMany: { 'profile.firstName' -> { '$regex' -> '^.*na.*'. '$options' -> 'i'} asDictionary } asDictionary). And I'd like to *$or* this with: 'profile.surname' -> { '$regex' ->

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-06 Thread Stéphane Ducasse
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano wrote: > sure :) > > I will add a blog post on "voyage advanced queries" too :) too if you want but we could also focus on the chapter because we can be multiple people to edit it while your blog you are alone. Stef > > Esteban > > On Jul 6,

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-06 Thread Esteban Lorenzano
sure :) I will add a blog post on "voyage advanced queries" too :) Esteban On Jul 6, 2013, at 10:52 AM, Stéphane Ducasse wrote: > esteban could you take some time to add this information to the Voyage > chapter? > > https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/ > >

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-06 Thread Stéphane Ducasse
Sorry but I hate this! We should be better at writing doc. I do not want to learn this because I ask in the mailing-list if you see what I mean. Now that Gutenberg is working we should use it for real It is based on github so people should be happy and it delivers pdf and html (and whatever will

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-06 Thread Stéphane Ducasse
esteban could you take some time to add this information to the Voyage chapter? https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/ add the information in any format and I can make it run. https://github.com/SquareBracketAssociates/PharoForTheEnterprise-english Ste

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
and btw, AFAIK MongoQueries does not have support for regexp, but would be easy to extend them to support it, something like: [ :each | each name regexpMatch: '^P*' options: 'i' ] which is of course more expressive than the dictionary :) Esteban On Jul 4, 2013, at 8:29 PM, Esteban Lorenzan

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Bernat Romagosa
Good to know! 2013/7/4 Esteban Lorenzano > you also have regexp expressions (and I think they are better than the > where clause): > > { > #name -> { > '$regex' -> '^P*'. > '$options' -> 'i' > } asDictionary > } asDictionary > > there is no support for it with MongoQueries, but they work fine

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
you also have regexp expressions (and I think they are better than the where clause): { #name -> { '$regex' -> '^P*'. '$options' -> 'i' } asDictionary } asDictionary there is no support for it with MongoQueries,

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban A. Maringolo
2013/7/4 Bernat Romagosa : > For other kinds of matches, you need javascript queries, if I understood: > > User selectOne: [ :each | each where: 'this.name[0] == "s"' ] > > Right? Just as a side note. Beware of the "$where" filter (it is: { "$where": this.that == 's' }), it deserializes the BSON

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
oops, is { "number_field": { $gt: 42 } } but well, you got the idea :) On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano wrote: > you have different constructions: > > { $gt: { "number_field": 42 } } > > and so on... always with dictionaries (bah, json structs). > > as a query language

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
you have different constructions: { $gt: { "number_field": 42 } } and so on... always with dictionaries (bah, json structs). as a query language it kinda sucks... but well... is how it is :) On Jul 4, 2013, at 7:34 PM, Stéphane Ducasse wrote: > Ok but how do I map conceptual a query to a dic

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Bernat Romagosa
For other kinds of matches, you need javascript queries, if I understood: User selectOne: [ :each | each where: 'this.name[0] == "s"' ] Right? 2013/7/4 Stéphane Ducasse > Ok but how do I map conceptual a query to a dictionary > > Do I guess right that there is an exact match > > selec

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Stéphane Ducasse
Ok but how do I map conceptual a query to a dictionary Do I guess right that there is an exact match selectOne: { id -> 10} asDictionary will match id = 10 Now we can only do exact mathc? name matches: 'stef*' On Jul 4, 2013, at 6:04 PM, Esteban A. Maringolo wrote: > Stef,

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
yes, is like my homonym says :) of course, this is restricted to Voyage and because of how Mongo works.. Esteban On Jul 4, 2013, at 6:04 PM, Esteban A. Maringolo wrote: > Stef, > > You're asking the other Esteban, but having used Voyage and Mongo I > think I can answer this. > > Mongo receiv

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban A. Maringolo
Stef, You're asking the other Esteban, but having used Voyage and Mongo I think I can answer this. Mongo receives a JSON object to do all the query filtering. For a simple lookup it is has a simple structre, as the query gets more complex it gets esoteric as well (with "special" MongoDB keys in t

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Stéphane Ducasse
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano wrote: > Hi :) > > can you check if you have the "MongoQueries" package installed? > > cheers, > Esteban > > ps: please notice that in anycase you will not be able to execute > > [ :each | each name first = $X ] > > because the MongoQueries pac

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Bernat Romagosa
I'm so ashamed I hadn't tried this before asking... a simple *ConfigurationOfMongoTalk load* did the job ¬¬ Thanks a lot! 2013/7/4 Esteban Lorenzano > Mmm... no idea... you could try by updating all the MongoTalk package, > probably is out of sync :) > > On Jul 4, 2013, at 4:28 PM, Bernat Roma

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
Mmm... no idea... you could try by updating all the MongoTalk package, probably is out of sync :) On Jul 4, 2013, at 4:28 PM, Bernat Romagosa wrote: > Hmm, none of the MongoQueries tests pass, giving the following #dnu: > > MessageNotUnderstood: BlockClosure>>bsonTypeCode > > I guess I'm mis

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Bernat Romagosa
Hmm, none of the MongoQueries tests pass, giving the following #dnu: MessageNotUnderstood: BlockClosure>>bsonTypeCode I guess I'm missing some packages? 2013/7/4 Bernat Romagosa > Hi Esteban, > > I installed MongoQueries-NicolasPetton.6, but I did it manually, should I > have used some Montic

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Bernat Romagosa
Hi Esteban, I installed MongoQueries-NicolasPetton.6, but I did it manually, should I have used some Monticello configuration perhaps? Thanks! 2013/7/4 Esteban Lorenzano > Hi :) > > can you check if you have the "MongoQueries" package installed? > > cheers, > Esteban > > ps: please notice tha

Re: [Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Esteban Lorenzano
Hi :) can you check if you have the "MongoQueries" package installed? cheers, Esteban ps: please notice that in anycase you will not be able to execute [ :each | each name first = $X ] because the MongoQueries package just translates the block into a mongo-query which is a dictionary (a JSON

[Pharo-users] [Voyage] #selectOne: and #selectMany: with a block as the argument

2013-07-04 Thread Bernat Romagosa
Hi! I realize probably only Esteban will be able to answer, but I prefer to write to the list so the mail is logged and other people can benefit from it. I'm trying to use blocks as arguments for #*selectOne:* and #*selectMany:*, but it doesn't seem to work. Here's my code: MyClass selectOne: {