[Voyage] #selectOne: and #selectMany: with a block as the argument
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ]. The first one works, but the second one raises a *VOMongoConnectionError*. Also: MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ]. The first does work, the second one doesn't, which prevents me from writing more useful stuff like: MyClass selectMany: [ :each | each name first = $P ]. Any idea why this could be failing? I've the latest stable version loaded via: Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load. Thanks! :) Bernat. -- Bernat Romagosa.
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 expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests) On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- 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 <estebanlm@gmail.com>
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 expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a *VOMongoConnectionError* .
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- 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 <tibabenfortlapalanca@gmail.com>
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 <estebanlm@gmail.com>
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 expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a *VOMongoConnectionError* .
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com> 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 <estebanlm@gmail.com> 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 expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- 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 <estebanlm@gmail.com>
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 < tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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 <estebanlm@gmail.com>
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 expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a *VOMongoConnectionError *.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work. Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
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 the format of "$key"). Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON. Regards, Esteban A. Maringolo 2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- 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 <stephane.ducasse@inria.fr>
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com>
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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will
found
some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
2013/7/4 Bernat Romagosa <tibabenfortlapalanca@gmail.com>:
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 for every value, converts it to the JavaScript object and then performs the comparison, it is not efficient in any way. There are lots of ways to perform the query using built-in operators instead of $where. (*) (*) Disclaimer: None of it is pretty in any way. Actually they're ugly. It's like specifiying an SQL WHERE statement with dictionaries, or worst, an Excel formula with Dictionaries. Having some sort of "intelligence" from the Smalltalk side converting comparison operators to their MongoDB counterparts is really useful. Regards,
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 with dictionaries :) Esteban On Jul 4, 2013, at 7:36 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> 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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
Good to know! 2013/7/4 Esteban Lorenzano <estebanlm@gmail.com>
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 with dictionaries :)
Esteban
On Jul 4, 2013, at 7:36 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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 <stephane.ducasse@inria.fr>
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com>
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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will
found
some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 be needed) So please join and help us building a real system. Stef
Good to know!
2013/7/4 Esteban Lorenzano <estebanlm@gmail.com> 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 with dictionaries :)
Esteban
On Jul 4, 2013, at 7:36 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> 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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 Lorenzano <estebanlm@gmail.com> wrote:
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 with dictionaries :)
Esteban
On Jul 4, 2013, at 7:36 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> 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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
oops, is { "number_field": { $gt: 42 } } but well, you got the idea :) On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
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 Stef On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
sure :) I will add a blog post on "voyage advanced queries" too :) Esteban On Jul 6, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- 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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary. 2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr>
wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com>
wrote:
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 <
stephane.ducasse@inria.fr> wrote:
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 <
emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary,
I
guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com>
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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will
found
some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- 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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <
stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com>
wrote:
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 <
stephane.ducasse@inria.fr> wrote:
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 <
emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the
Dictionary, I
guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com>
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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you
will found
some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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') = (VORepository current keyOf: referenceObject) ] Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure: { '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. } so, you always can construct queries knowing that :) Esteban On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com> 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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
Esteban, Why do you use __id: (double underscore) instead of the _id (single underscore) key? Regards, Esteban A. Maringolo 2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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" <emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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. Maringolo 2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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" <emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 <emaringolo@gmail.com> wrote:
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. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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" <emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 <emaringolo@gmail.com> wrote:
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. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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" <emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- 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.*'. '$options' -> 'i' } * asDictionary *} *asDictionary*) } *asDictionary*. With so many dictionaries it's really easy to miss one! :) Thanks a lot, I've got everything working now! 2013/7/8 Stéphane Ducasse <stephane.ducasse@inria.fr>
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 <emaringolo@gmail.com> wrote:
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. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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" < emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com
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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <
estebanlm@gmail.com>
wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block
into a
mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
and that is one reason why a special syntax for dictionaries would be welcome :) On Jul 9, 2013, at 11:42 AM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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.*'. '$options' -> 'i' } asDictionary } asDictionary) } asDictionary.
With so many dictionaries it's really easy to miss one! :)
Thanks a lot, I've got everything working now!
2013/7/8 Stéphane Ducasse <stephane.ducasse@inria.fr> 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 <emaringolo@gmail.com> wrote:
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. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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" <emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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 <tibabenfortlapalanca@gmail.com> wrote:
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.*'. '$options' -> 'i' } asDictionary } asDictionary) } asDictionary.
With so many dictionaries it's really easy to miss one! :)
Thanks a lot, I've got everything working now!
2013/7/8 Stéphane Ducasse <stephane.ducasse@inria.fr> 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 <emaringolo@gmail.com> wrote:
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. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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" <emaringolo@gmail.com> wrote:
Esteban,
Why do you use __id: (double underscore) instead of the _id (single underscore) key?
Regards, Esteban A. Maringolo
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>:
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') = (VORepository current keyOf: referenceObject) ]
Some internal info: in Voyage, all references are kept in mongo as sub-documents with this structure:
{ '__id': OID(1234567890). '#collection': 'theNameOfTheCollection'. }
so, you always can construct queries knowing that :)
Esteban
On Jul 8, 2013, at 12:58 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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 <tibabenfortlapalanca@gmail.com>
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
Hi, something like this: { '$or'-> { { $field1 -> value1 } asDictionary. "expression 1" { $field2 -> value2 } asDictionary. "expression 2" ... { $fieldN -> valueN } asDictionary. "expression N" } } asDictionary cheers, Esteban On Jul 8, 2013, at 12:16 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- 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' -> { '$regex' -> '^.*ve.*'. '$options' -> 'i'} asDictionary. } asDictionary } asDictionary. But it's obviously wrong... :( 2013/7/8 Esteban Lorenzano <estebanlm@gmail.com>
Hi,
something like this:
{ '$or'-> { { $field1 -> value1 } asDictionary. "expression 1" { $field2 -> value2 } asDictionary. "expression 2" ... { $fieldN -> valueN } asDictionary. "expression N" } } asDictionary
cheers, Esteban
On Jul 8, 2013, at 12:16 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <
stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com>
wrote:
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 <
stephane.ducasse@inria.fr> wrote:
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 <
emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the
Dictionary, I
guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com>
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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you
will found
some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa < tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
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'} asDictionary with: 'profile.surname' -> { '$regex' -> '^.*ve.*'. '$options' -> 'i'} asDictionary) } asDictionary. On Jul 8, 2013, at 2:16 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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' -> { '$regex' -> '^.*ve.*'. '$options' -> 'i'} asDictionary. } asDictionary } asDictionary.
But it's obviously wrong... :(
2013/7/8 Esteban Lorenzano <estebanlm@gmail.com> Hi,
something like this:
{ '$or'-> { { $field1 -> value1 } asDictionary. "expression 1" { $field2 -> value2 } asDictionary. "expression 2" ... { $fieldN -> valueN } asDictionary. "expression N" } } asDictionary
cheers, Esteban
On Jul 8, 2013, at 12:16 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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' -> '^.*ve.*'. '$options' -> 'i'} asDictionary.
2013/7/6 Stéphane Ducasse <stephane.ducasse@inria.fr>
On Jul 6, 2013, at 11:16 AM, Esteban Lorenzano <estebanlm@gmail.com> 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, 2013, at 10:52 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
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
Stef
On Jul 4, 2013, at 7:49 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
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 <stephane.ducasse@inria.fr> wrote:
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 <emaringolo@gmail.com> wrote:
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 the format of "$key").
Because the simplest map we have to a JSON Object is the Dictionary, I guess that's why it ends up being converted to a Dictionary, which in turn gets converted to JSON and/or BSON.
Regards,
Esteban A. Maringolo
2013/7/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
On Jul 4, 2013, at 2:58 PM, Esteban Lorenzano <estebanlm@gmail.com> 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 package just translates the block into a mongo-query which is a dictionary (a JSON expression). But you will found some ways to help you, some special keywords like #in: and #where: (you can see how they work in the tests)
esteban how a dictionary is used to work as a block for a query? Can you explain because I would have thought that the first line did not work and the second would work.
Stef
On Jul 4, 2013, at 2:17 PM, Bernat Romagosa <tibabenfortlapalanca@gmail.com> wrote:
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: { #name -> 'Some name' } asDictionary. MyClass selectOne: [ :each | each name = 'Some name' ].
The first one works, but the second one raises a VOMongoConnectionError.
Also:
MyClass selectMany: { #name -> 'Some name' } asDictionary. MyClass selectMany: [ :each | each name = 'Some name' ].
The first does work, the second one doesn't, which prevents me from writing more useful stuff like:
MyClass selectMany: [ :each | each name first = $P ].
Any idea why this could be failing? I've the latest stable version loaded via:
Gofer it url: 'http://smalltalkhub.com/mc/estebanlm/Voyage/main'; package: 'ConfigurationOfVoyageMongo'; load. (Smalltalk at: #ConfigurationOfVoyageMongo) load.
Thanks! :)
Bernat.
-- Bernat Romagosa.
-- Bernat Romagosa.
-- Bernat Romagosa.
participants (4)
-
Bernat Romagosa -
Esteban A. Maringolo -
Esteban Lorenzano -
Stéphane Ducasse