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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

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

Version Location Description Submitted By Date submitted Date corrected
Printed
Page 10,174
Third paragraph on page 10, Last paragraph on page 174.

You claim that the default directory on windows is
c:\data\db. Its actually \data\db of the current drive. I've just
verified, using the latest 64 bit windows binaries from mongodb.org,
that its the drive of the working directory, and not the drive where
the binaries are located.

From the point of view of the command line, the working directory is
the drive you are currently on. However, if you create a windows
shortcut or make and API call to CreateProcess(), you can set the
windows shortcut.

Console output to demonstrate it:

E:\mongodb-win32-x86_64-2010-09-24\bin>mongod
C:\Users\zippy\Downloads\mongodb-win32-x86_64-2010-09-24\bin\mongod.EXE
--help for help and startup options
Fri Sep 24 20:40:18 MongoDB starting : pid=7680 port=27017
dbpath=/data/db/ 64-bit

** NOTE: This is a development version (1.7.1-pre-) of MongoDB.
** Not recommended for production.

Fri Sep 24 20:39:11 db version v1.7.1-pre-, pdfile version 4.5
Fri Sep 24 20:39:11 git version: 507389045b252b7ce16bac661839ead3ba7fb185
Fri Sep 24 20:39:11 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Fri Sep 24 20:39:11 exception in initAndListen std::exception: dbpath
(/data/db/) does not exist, terminating
Fri Sep 24 20:39:11 dbexit:
Fri Sep 24 20:39:11 shutdown: going to close listening sockets...
Fri Sep 24 20:39:11 shutdown: going to flush oplog...
Fri Sep 24 20:39:11 shutdown: going to close sockets...
Fri Sep 24 20:39:11 shutdown: waiting for fs preallocator...
Fri Sep 24 20:39:11 shutdown: closing all files...
Fri Sep 24 20:39:11 closeAllFiles() finished
Fri Sep 24 20:39:11 dbexit: really exiting now

E:\mongodb-win32-x86_64-2010-09-24\bin>C:\Users\zippy\Downloads\mongodb-win32-x86_64-2010-09-24\bin\mongod
C:\Users\zippy\Downloads\mongodb-win32-x86_64-2010-09-24\bin\mongod.EXE
--help for help and startup options
Fri Sep 24 20:40:18 MongoDB starting : pid=7680 port=27017
dbpath=/data/db/ 64-bit

** NOTE: This is a development version (1.7.1-pre-) of MongoDB.
** Not recommended for production.

Fri Sep 24 20:40:18 db version v1.7.1-pre-, pdfile version 4.5
Fri Sep 24 20:40:18 git version: 507389045b252b7ce16bac661839ead3ba7fb185
Fri Sep 24 20:40:18 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Fri Sep 24 20:40:18 exception in initAndListen std::exception: dbpath
(/data/db/) does not exist, terminating
Fri Sep 24 20:40:18 dbexit:
Fri Sep 24 20:40:18 shutdown: going to close listening sockets...
Fri Sep 24 20:40:18 shutdown: going to flush oplog...
Fri Sep 24 20:40:18 shutdown: going to close sockets...
Fri Sep 24 20:40:18 shutdown: waiting for fs preallocator...
Fri Sep 24 20:40:18 shutdown: closing all files...
Fri Sep 24 20:40:18 closeAllFiles() finished
Fri Sep 24 20:40:18 dbexit: really exiting now

E:\mongodb-win32-x86_64-2010-09-24\bin>start mongod2
*****************************END CONSOLE OUTPUT
******************************************************

mongod2 was a windows shortcut to mongod.exe that changed the working
director to "c:\windows" That opened a new cmd.exe shell with the
following output:

E:\mongodb-win32-x86_64-2010-09-24\bin\mongod.exe --help for help and startup op
tions
Fri Sep 24 20:54:24 MongoDB starting : pid=15220 port=27017 dbpath=/data/db/ 64-
bit

** NOTE: This is a development version (1.7.1-pre-) of MongoDB.
** Not recommended for production.

Fri Sep 24 20:54:24 db version v1.7.1-pre-, pdfile version 4.5
Fri Sep 24 20:54:24 git version: 507389045b252b7ce16bac661839ead3ba7fb185
Fri Sep 24 20:54:24 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42

Fri Sep 24 20:54:24 [initandlisten] waiting for connections on port 27017
Fri Sep 24 20:54:24 [websvr] web admin interface listening on port 28017ou claim that the default directory on windows is
c:\data\db. Its actually \data\db of the current drive. I've just
verified, using the latest 64 bit windows binaries from mongodb.org,
that its the drive of the working directory, and not the drive where
the binaries are located.

From the point of view of the command line, the working directory is
the drive you are currently on. However, if you create a windows
shortcut or call the windows equivalent of exec(), you can set the
windows shortcut.

I'm looking forward to getting through the rest of the book and I will
post a review on bn.com.

Justin

Console output to prove it:

E:\mongodb-win32-x86_64-2010-09-24\bin>mongod
C:\Users\zippy\Downloads\mongodb-win32-x86_64-2010-09-24\bin\mongod.EXE
--help for help and startup options
Fri Sep 24 20:40:18 MongoDB starting : pid=7680 port=27017
dbpath=/data/db/ 64-bit

** NOTE: This is a development version (1.7.1-pre-) of MongoDB.
** Not recommended for production.

Fri Sep 24 20:39:11 db version v1.7.1-pre-, pdfile version 4.5
Fri Sep 24 20:39:11 git version: 507389045b252b7ce16bac661839ead3ba7fb185
Fri Sep 24 20:39:11 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Fri Sep 24 20:39:11 exception in initAndListen std::exception: dbpath
(/data/db/) does not exist, terminating
Fri Sep 24 20:39:11 dbexit:
Fri Sep 24 20:39:11 shutdown: going to close listening sockets...
Fri Sep 24 20:39:11 shutdown: going to flush oplog...
Fri Sep 24 20:39:11 shutdown: going to close sockets...
Fri Sep 24 20:39:11 shutdown: waiting for fs preallocator...
Fri Sep 24 20:39:11 shutdown: closing all files...
Fri Sep 24 20:39:11 closeAllFiles() finished
Fri Sep 24 20:39:11 dbexit: really exiting now

E:\mongodb-win32-x86_64-2010-09-24\bin>C:\Users\zippy\Downloads\mongodb-win32-x86_64-2010-09-24\bin\mongod
C:\Users\zippy\Downloads\mongodb-win32-x86_64-2010-09-24\bin\mongod.EXE
--help for help and startup options
Fri Sep 24 20:40:18 MongoDB starting : pid=7680 port=27017
dbpath=/data/db/ 64-bit

** NOTE: This is a development version (1.7.1-pre-) of MongoDB.
** Not recommended for production.

Fri Sep 24 20:40:18 db version v1.7.1-pre-, pdfile version 4.5
Fri Sep 24 20:40:18 git version: 507389045b252b7ce16bac661839ead3ba7fb185
Fri Sep 24 20:40:18 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42
Fri Sep 24 20:40:18 exception in initAndListen std::exception: dbpath
(/data/db/) does not exist, terminating
Fri Sep 24 20:40:18 dbexit:
Fri Sep 24 20:40:18 shutdown: going to close listening sockets...
Fri Sep 24 20:40:18 shutdown: going to flush oplog...
Fri Sep 24 20:40:18 shutdown: going to close sockets...
Fri Sep 24 20:40:18 shutdown: waiting for fs preallocator...
Fri Sep 24 20:40:18 shutdown: closing all files...
Fri Sep 24 20:40:18 closeAllFiles() finished
Fri Sep 24 20:40:18 dbexit: really exiting now

E:\mongodb-win32-x86_64-2010-09-24\bin>start mongod2

*************END CONSOLE OUTPUT*************


mongod2 was a windows shortcut to mongod.exe that changed the working
director to "c:\windows" That opened a new cmd.exe shell with the
following output:

E:\mongodb-win32-x86_64-2010-09-24\bin\mongod.exe --help for help and startup op
tions
Fri Sep 24 20:54:24 MongoDB starting : pid=15220 port=27017 dbpath=/data/db/ 64-
bit

** NOTE: This is a development version (1.7.1-pre-) of MongoDB.
** Not recommended for production.

Fri Sep 24 20:54:24 db version v1.7.1-pre-, pdfile version 4.5
Fri Sep 24 20:54:24 git version: 507389045b252b7ce16bac661839ead3ba7fb185
Fri Sep 24 20:54:24 sys info: windows (6, 1, 7600, 2, '') BOOST_LIB_VERSION=1_42

Fri Sep 24 20:54:24 [initandlisten] waiting for connections on port 27017
Fri Sep 24 20:54:24 [websvr] web admin interface listening on port 28017

Note from the Author or Editor:
C:\data\db should be \data\db.

Justin Dearing  Sep 27, 2010 
PDF
Page 14
Next to last paragraph

"by db.help();, and help at the collec- tions can be accessed"

This would probably read a bit smoother if changed to "at the collections level". Also, I don't think a comma is grammatically correct in that sentence, though it may be stylistically useful to clarify that the preceding semicolon is part of the expression. Or perhaps rewording and avoiding the passive would be better. For example:

Use db.help() for database-level commands and db.foo.help() for collection-level commands.

Note from the Author or Editor:
Yes, that isn't very well-phrased. It would probably sound better if it were something like: "You can also get database-level help by running db.help() or collection-level help with db.foo.help()."

Robert Stewart  Oct 06, 2010 
Printed
Page 17
Not sure, don't have the book handy

The term "BSON" is used without an prior explanation. I had to look in the index to find out for sure what it is.

Andy Leste  Oct 11, 2010 
Printed
Page 31
first paragraph and fourth paragraph

In the example results for db.games.findOne(), the key "name" should be "user". Likewise, slightly further down the page, the results for db.games.find() should also have the key "name" replaced with "user".

Note from the Author or Editor:
Thank you! I've corrected this for the second edition.

Anonymous  Sep 19, 2012 
PDF
Page 32
2nd paragraph

"simple" should be "simply"

Robert Stewart  Oct 21, 2010 
PDF
Page 32
code

The example seems to work if you put double quotes around the $push.

Note from the Author or Editor:
"$push" doesn't have to be in quotes, but it's stylistically nicer.

Mike Sweeney  Sep 22, 2011 
PDF
Page 32
code

The example seems to work if you put double quotes around the $push.

Note from the Author or Editor:
"$push" doesn't actually have to be in double quotes to work, but it's stylistically nicer.

Mike Sweeney  Sep 22, 2011 
PDF
Page 39
1st example code (after 2nd paragraph

should be db.movies.update(), not db.movies.find().

Note from the Author or Editor:
Correct, for both db.movies snippets.

Anonymous  Sep 26, 2013 
PDF
Page 40
runCommand

ps = db.runCommand({"findAndModify" : "processes",
... "query" : {"status" : "READY"},
... "sort" : {"priority" : -1},
... "update" : {"$set" : {"status" : "RUNNING"}})
**********************************************************
should be (need one more right squigly):
**********************************************************
ps = db.runCommand({"findAndModify" : "processes",
... "query" : {"status" : "READY"},
... "sort" : {"priority" : -1},
... "update" : {"$set" : {"status" : "RUNNING"}}})

Note from the Author or Editor:
Correct, thank you.

Mike Sweeney  Sep 23, 2011 
Printed
Page 41
13th line

Explaining the "findAndModify"-Command you say there is no possibility to use it for an upsert but indeed there is one: you can specify the parameter "upsert:true" to create the document if it does not exist.

(http://docs.mongodb.org/manual/reference/command/findAndModify/)

Note from the Author or Editor:
When the first edition was written, upsert was not an available option. The second edition includes this option.

Dorothea Gugler  Jan 10, 2014 
Printed
Page 42
2nd paragraph

The paragraph states that safe versions of these operations exist or at least implies it. But there is no reference to how these safe operations are named and according to the documentation there's no safe option either.

Explanation: The safe version runs a getLastError command immediately...

This implies that a safe version exists, but where, how.

Of course I can run a getLastError command manually, but then the above sentence has to be re-written to something like:

If you want to run a safe version of the commands, you will have to issue a getLastError command right after the actual command to retrieve the status information about the operation.

Note from the Author or Editor:
Since the first edition was published, the drivers have standardized on the term "write concern" instead of "safe." You should look up instructions for using "write concern" for whatever language you're using (e.g., Javadoc is here: http://api.mongodb.org/java/2.9.2/com/mongodb/WriteConcern.html and PHP doc is here: http://php.net/manual/en/mongo.writeconcerns.php).

Helmut K. C. Tessarek  Dec 16, 2014 
Printed
Page 49
middle - db.runCommand

The db.runCommand ( { "findAndModify" .........

in the middle of the page

should be closed with }}} ) ;

It is with }} ) ; only.






Peter Petrov  Feb 07, 2014 
PDF
Page 52
$size section

db.food.update({"$push" : {"fruit" : "strawberry"}})
should be
db.food.update(criteria, {"$push" : {"fruit" : "strawberry"}})

and for the same reason,
db.food.update({"$push" : {"fruit" : "strawberry"}, "$inc" : {"size" : 1}})
should be
db.food.update(criteria, {"$push" : {"fruit" : "strawberry"}, "$inc" : {"size" : 1}})

Note from the Author or Editor:
Whoops, thank you!

sunqiang  Nov 05, 2011 
PDF, ePub
Page 52
last 3 lines

It's a bit question about the number of elements by $slice.
I found here,

"> db.blog.posts.findOne(criteria, {"comments" : {"$slice" : [23, 10]}})
This would skip the first 23 elements and return the 24th through 34th. If there are
fewer than 34 elements in the array, it will return as many as possible."

I think $slice with [23,10], skips 23 elements(correct in the book), and get 10 elements. But the number from 24 to 34 is not "10" but "11".

Therefore the sentence just after the sample code should be changed the last word from "34th" to "33rd" like,
"This would skip the first 23 elements and return the 24th through 33rd. "

Is it correct?

Note from the Author or Editor:
You are correct! One-off error.

Kazuyoshi Hayase  Oct 24, 2012 
PDF
Page 56
First Code block

var cursor = db.collection.find(); should be var cursor = db.c.find();

Note from the Author or Editor:
Whoops, you're correct.

Tom Krouper  Oct 15, 2010 
Printed
Page 66
after 5th paragraph

it says

db.ensureIndex({ "date" : 1, "username": 1})

when clearly it should say:

db.posts.ensureIndex({ "date" : 1, "username": 1})

yes?

Note from the Author or Editor:
Whoops, it should say:

db.people.ensureIndex(...

Thanks for the heads up!

Andrew Watson  Mar 28, 2011 
Printed, PDF, , Other Digital Version
Page 71
definition list

The "nscanned" item refers to the number of index entries scanned, not the number of documents scanned (nscannedObjects).

Note from the Author or Editor:
It's actually either, but the book should have definitions for both:

nscanned: If a query is using an index, this is the number of index entries examined. If a query is not using an index, it is the number of documents examined (same as nscannedObjects).
nscannedObjects: The number documents looked at.

Markus Gattol  Nov 03, 2010 
Printed, PDF, , Other Digital Version
Page 85
Both code examples on the page

The key field should be {"day" : true}. So, instead of:

... "key" : {"tags" : true},

it should be

... "key" : {"day":true},

both places it appears on this page.

Kristina Chodorow
Kristina Chodorow
 
Nov 02, 2010 
Printed, PDF, , Other Digital Version
Page 90
The definition list

"output" should be "out", so the third item should read:

"out" : string
Name for the output collection. Setting this...

Kristina Chodorow
Kristina Chodorow
 
Nov 02, 2010 
Printed, PDF
Page 107
1st Paragraph

Grammar error: "identifying a reference to document" should be "identifying a reference to a document"

bigoldfaty  Jan 14, 2011 
Printed, PDF, , Other Digital Version
Page 123
fsync and Lock section, first paragraph, second sentence

This could be construed to mean that running mongodump can cause corruption. It cannot, and should read:

"As recent writes may exist only in memory or be halfway through being written to disk, using mongodump on a live database may result in an unusable backup of the data. MongoDB's fsync command flushes writes and locks the database, allows us to get a perfect copy the data directory of a running MongoDB server."

Kristina Chodorow
Kristina Chodorow
 
Nov 04, 2010