The upsert example
$pageviews->update({"url" => "www.example.com"},
{"url" => "www.example.com", '$inc' => {"views" => 1}},
{'upsert' => 1});
mentioned on http://search.cpan.org/~kristina/MongoDB/lib/MongoDB/Tutorial.pod does
not work for me.
The error mongod reports is:
Fri Apr 16 15:46:04 update tutorial.pageview query: { url: "www.example.com" } exception
userassert:Invalid modifier specifiedurl 0ms
This appears to be working fine instead:
$pageviews->update({"url" => "www.example.com"},
{'$inc' => {"views" => 1}},
{'upsert' => 1});
No errors are reported, and records are inserted or updated as expected. This syntax is also
similar to instructions provided on
http://www.mongodb.org/display/DOCS/Updating#Updating-UpsertswithModifiers -
example:
db.people.update( { name:"Joe" }, { $inc: { x:1, y:1 } }, true );
I'm just now starting to learn about MongoDB, so I'm not certain if I have found a real bug or
if I'm misunderstanding the Tutorial.