Hi,
I managed reading and writing my model (e.g. Person objects) into MongoDB
with MongoTalk.
But I did use replace:with:
e.g.
"get person from db with OID -
this is a dictionary with ALL OLD fields of the person as stored in the
database"
thePersonFromDatabaseDict := (self personsCollection queryOne: [ :query |
query where: {('_id' -> aPerson mongoObjectId )} asDictionary ])
theNewDict := aPerson mongoDataDict
"dictionary with the NEW fields for this person"
self personsCollection
replace: thePersonFromDatabaseDict
with: theNewDict
Which means I replace the whole person object in the database with my
current instance data in the image. Also it is much overhead creating the
dictionary with all fields from the person in the image.
This is not ok, when I want to set e.g. one field in the person object.
For this reason I want to use the "Modifier operators", e.g. $set
http://docs.mongodb.org/manual/applications/update/
>From there:
"Update a Field in a Document. Use $set to update a value of a field. The
following operation queries the bios collection for the first document that
has an _id field equal to 1 and sets the value of the field middle, in the
subdocument name, to Warner:
db.bios.update(
{ _id: 1 },
{
$set: { 'name.middle': 'Warner' },
}
)
*I did not find how to use this in MongoTalk. I can not imagine that this
functionality is missing but I don't know how to create this from Mongotalk.
Unfortunately there is no documentation and as far as I understand there are
no test cases for update modifiers.*
So, can anyone give me a code snippet how to use update modifiers in
Mongotalk?
Sabine
--
View this message in context:
http://forum.world.st/does-MongoTalk-implement-modifier-operators-e-g-set-tp4675511.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.