Errata

MongoDB: The Definitive Guide

Errata for MongoDB: The Definitive Guide

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF

> var timeRemoves = function() {
...
... db.tester.remove();
...
... }

db.tester.remove();
should be:
db.tester.remove({});

Tested:
2015-11-06T19:07:20.571-0800 E QUERY Error: remove needs a query
at Error (<anonymous>)
at DBCollection._parseRemove (src/mongo/shell/collection.js:305:32)
at DBCollection.remove (src/mongo/shell/collection.js:328:23)
at (shell):1:8 at src/mongo/shell/collection.js:305

*https://github.com/mongodb/mongo/commit/a56fff30fbe28b90ad3526fb285dec078be72979#diff-ad54c6cd77e7be86c6ba069e15dd842b

Validation of remove arguments added here on Feb 2, 2014. Seems to be post-publishing :)

Saif Aljashamy  Nov 06, 2015 
PDF Page 31
Under Removing Documents header

> db.foo.remove()

should be:
db.foo.remove({})

Tested:
2015-11-06T19:07:20.571-0800 E QUERY Error: remove needs a query
at Error (<anonymous>)
at DBCollection._parseRemove (src/mongo/shell/collection.js:305:32)
at DBCollection.remove (src/mongo/shell/collection.js:328:23)
at (shell):1:8 at src/mongo/shell/collection.js:305

*https://github.com/mongodb/mongo/commit/a56fff30fbe28b90ad3526fb285dec078be72979#diff-ad54c6cd77e7be86c6ba069e15dd842b

Validation of remove arguments added on Feb 2, 2014. Seems to be post-publishing; technically not a mistake, I can't seem to select update.

Saif Aljashamy  Nov 06, 2015 
PDF Page 37
the paragraph before 'Array Modifiers'

s/Modifier "$inc" allowed numbers only/ Cannot increment with non-numeric argument: {"count" : "1"}/

Dimid Duchovny  Jul 01, 2015 
Printed Page 39
1st paragraph

The text shows:
> db.movies.find({"genre" : "horror"},
. . . {"push" : {"top10" : {
. . . "$each": ["Nightmare on Elm Street", "$Saw" ],
. . . "$slice": -10 }}})

When `update` should have been called on the collection, instead of `find`:
> db.movies.update({"genre" : "horror"},
. . . {"push" : {"top10" : {
. . . "$each": ["Nightmare on Elm Street", "$Saw" ],
. . . "$slice": -10 }}}

Brady Shutt  Sep 17, 2016 
Printed Page 63
$elemMatch sample

missing closing brace at the end of the query

db.test.find({"x" : {"$elemMatch" : {"$gt" : 10, "$lt" : 20}} } )

Miguel Ángel Ocaña Silva  Dec 28, 2014 
PDF Page 63
3rd paragraph

the first clause (it is greater than 10) NOT 25

Bertrand Greff  Oct 05, 2015 
PDF Page 65
1st paragraph

May be you can add that the result of the right query have to be empty.

Bertrand Greff  Oct 05, 2015 
PDF Page 71
Code Segment

The distribution of the returned documents won't be discretely uniform as the probability of each document getting fetched is determined by u(0,1) samples rather than a constant.

This would work (though I'm guessing there might be a race condition on calls to count() and inserts which might need to be addressed if rows are inserted concurrently):

db.people.insert({"name" : "joe", "random" : db.people.count()})
db.people.insert({"name" : "john", "random" : db.people.count()})
db.people.insert({"name" : "jim", "random" : db.people.count()})

var random = Math.floor(db.people.count()*Math.random())

...

result = db.foo.findOne({"random" : random})

Eric Vallee  Sep 04, 2014 
Printed Page 120
2nd example

it says the GeoJSON type is Line, but it should be LineString

"loc" : { "type" : "Line", ...}

Miguel Ángel Ocaña Siva  Jan 03, 2015 
Printed, PDF, ePub Page 194
Figure 10-4

The "Op" numbers in the DC2 part of the diagram are inconsistent with the text and figure 10-5. The diagram should show that the database instances in DC2 have accepted writes up to number 131'.

Neil Smith  Mar 11, 2015 
PDF Page 237
Command after last paragraph

Chapter 13 Introduction to Sharding

Page 237 - Command after last paragraph
db.users.find({username: "user12345"}}).explain()

This above command includes extra closing curly brace
Expected: db.users.find({username: "user12345"}).explain()

Anilkumar Kalshetti  Dec 01, 2015