Susan Harkins (264) [Avatar] Offline
Please share errors in the published version of MongoDB in Action here. We'll publish a comprehensive list for everyone's convenience. Thank you!

Susan Harkins
Errata Editor
103204 (3) [Avatar] Offline
In the mongodb book for second edition. I see a number of _id keys repeating.

Like for example _id value for a review is identical to an _id value for voter_id

see the below example

[b]        "_id" : ObjectId("4c4b1476238d3b4dd5000041"),
[/b]        "product_id" : ObjectId("4c4b1476238d3b4dd5003981"),
        "date" : ISODate("2010-06-07T07:00:00Z"),
        "title" : "Amazing",
        "text" : "Has a squeaky wheel, but still a darn good wheel barrow.",
        "rating" : 4,
        "user_id" : ObjectId("4c4b1476238d3b4dd5000001"),
        "username" : "dgreenthumb",
        "helpful_votes" : 3,
        "voter_ids" : [
[b]                ObjectId("4c4b1476238d3b4dd5000041"),
[/b]                ObjectId("7a4f0376238d3b4dd5000003"),

this confuses a lot of people who are trying to learn from scratch.

103204 (3) [Avatar] Offline
One more..

On page 169 when you shouw how to update the shopping cart with upsert.

you have got the addition wrong.

cart item

cart_item = {
_id: ObjectId("4c4b1476238d3b4dd5003981"),
slug: "wheel-barrow-9092",
sku: "9092",
name: "Extra Large Wheel Barrow",
pricing: {
retail: 5897,
sale: 4897

then the update

selector = {
user_id: ObjectId("4c4b1476238d3b4dd5000001"),
state: 'CART'
update = {
$inc: {
sub_total: cart_item['pricing']['sale']
db.orders.update(selector, update, {upsert: true})

the subtotal shown in the output looks to be incorrect.

user_id: ObjectId("4c4b1476238d3b4dd5000001"),
state: 'CART',
subtotal: 9794

Can you please confirm ?
406940 (1) [Avatar] Offline
The sum is correct as it is the sale price x 2.
Ping (3) [Avatar] Offline
Error on page 155

outdoors_id = ObjectId("4c4b1476238d3b4dd5003982")
doc = db.categories.findOne({_id: outdoors_id}) = "The Great Outdoors"
db.categories.update({_id: outdoors_id}, doc)
  {'ancestors._id': outdoors_id},
  {$set: {'ancestors.$': doc }},  
  {multi: true})

Above, using 'doc' on ' {$set: {'ancestors.$': doc }},' to set the value of an array element is wrong, because it contains more elements including ancestors array.