Errata

Building Node Applications with MongoDB and Backbone

Errata for Building Node Applications with MongoDB and Backbone

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
7, 8,10
Examples detailed below

Safari doesn't list page numbers.

Example 7-2, 8-18, 10-24:
define([... 'views/Status'],
should be:
define([... 'views/status'],

Example 8-8:
define(['SocialNetView', 'models/Contact', 'views/Contact',
should be
define(['SocialNetView', 'models/Contact', 'views/contact',

In each, not the case of the last view. Starting with Example 7, none of these work on Linux, which has a case-sensitive file system. Changing the code to lower case fixes this.

This is already marked on the github repo, by somebody else.

Neil Bryant  Dec 29, 2012 
ePub Page 10
United Kingdom

On page 10, the text and code suggests that this ternary operator

name ? name.toLowerCase() : ''

involves setting the name variable.

"Inside the switch statement I used a ternary operator as shorthand for an if/else statement:
name ? name.toLowerCase() :: ''. This is equivalent to a much longer block
of code that checks whether the name variable exists, and if so, returns it as a lowercase
string, or otherwise sets it to an empty string for comparison:
if ( null != name ) {
name = name.toLowerCase();
} else {
name = '';
}"

As it stands, I think this will cause confusion. The text should be changed and the "equivalent" code becomes

if ( null != name ) {
return name.toLowerCase();
} else {
return ";
}

Philip Westwell  Feb 12, 2013 
PDF, Other Digital Version Page 17
Example 2-8

The line:

script(script(type='text/javascript')
var socket = io.connect('http://localhost:8080');
...


Sould be:

script(script(type='text/javascript').
var socket = io.connect('http://localhost:8080');
...


The period at the end of the `script` line is missing in the text, and in the code samples on github.

Benjamin  Sep 05, 2015 
PDF Page 45
top of the page

Every path:
public/js/lib/backbone.js
public/js/lib/jquery.js
public/js/lib/require.js

should have /libs/ instead of /lib/.

Anonymous  Jan 12, 2013 
PDF Page 50
top of the page, example 5-4

Why use relative path in: templates: '../templates' ?
templates: '/templates' is enough.

Anonymous  Jan 12, 2013 
PDF Page 70
Example 6-15

When at the end of chapter 7 and testing the reset password functionality, this generates an error on the resetPassword.jade template on:

extends layout

no such file or directory '/Users/dev-admin/Documents/Projects/SocialNet/views/layout.jade

which shows the path is wrong - it should look in the public directory.

peter_lorent  Feb 09, 2013 
PDF Page 72
Deutschland

At page 72 the author uses a config variable like

var config = {
mail: require('./config/mail')
}

but does not explains what is will contain and the folder structure ./config/mail does not exists.

Basit Qadeer  Feb 25, 2013 
PDF Page 72
Example 6-19

a mail.js file is expected in the code block:

var config = {
mail: require('./config/mail')
};

but the contents of the mail.js are never discussed or clarified. Missing this, the application crashes every time, as the Account model will not instantiate.

Tobias Parent  Aug 18, 2017 
Printed Page 79
United States

In the second paragraph after the code sample:

"...the view's HTML template to Underscore's ._template function."

should be:

"...the view's HTML template to Underscore's _.template function."

Brandon Taylor  Jan 10, 2013 
PDF Page 83
second paragraph

Where you say:

Because the StatusView class defines the list item (<li>) as the placeholder,

the declaration of the StatusView view class is missing in the chapter.

peter_lorent  Feb 09, 2013 
PDF Page 88
Bottom, first paragraph

The text states:

Next, AccountSchema is defined?take special notice of the email field that has its index property set to true.

However, the code listing on the page doesn't show the index property but only shows the unique property. Please clarify how the index property should be set.

Peter Lorent  Feb 09, 2013 
PDF Page 89
Under Backbone, first paragraph

Talking about the router, the text states:

it is the router?s job to kick off the data population tasks, authenticate the user, and move between the new views.

About the part: 'authenticate the user'

Is this not the task of SocialNet.js?

peter_lorent  Feb 09, 2013 
PDF Page 89
Putting it together

At the end of chapter 7 when trying the code, after the login nothing happens. The code in register.js only logs the data instead of going to the index. I've changed the code and send you a pull request.

peter_lorent  Feb 09, 2013 
PDF Page 94
end of chapter

At the end of chapter 7 you have omitted the declaration of the SocialNetView view class. When following the chapters and adding code yourself, the code won't run.

peter_lorent  Feb 09, 2013 
Printed Page 98
Example 8-5 views/contact.js

the line: var $responseArea = this.$('.actionArea'); should read :
var $responseArea = this.$('.actionarea');

Akim Delli  Mar 09, 2014 
Mobi Page 164, 217
Examples 7-15 and 8-24

In both code snippets from Example 7-15 (The account model) and 8-24 (The updated account.js model), there is a Status argument that is never passed.

module.exports = function(config, mongoose, Status, nodemailer) {

The problem is in file models/Account.js, that defines the moongose Account model.

In the app.js, from both chapters 7 and 8, the Account model is created without a Status argument.

The error related to this code occurs when nodemailer is used, in the function Account.forgotPassword.
As the third argument in app.js is put into the Status argument, nodemailer becomes undefined.

So, the error is:
TypeError: Cannot call method 'createTransport' of undefined


To corret this error, just remove the Status argument from Examples 7-15 and 8-24.

Alexandre Aquiles  Feb 23, 2013 
Mobi Page 183
1st paragraph

In chapter 8, section "Contact List Template", it says:

"Looking back at the Contact List view in Example 8-2, the contacts will live inside an unordered list (<ul>) HTML tag."

Though, looking at Example 8-2, there is no <ul> but a <div>.

As the Example 8-5 defines the contact.js view with a 'li' tagname, a contact is present with a bullet point on the side.

Alexandre Aquiles  Feb 23, 2013 
Mobi Page 192
Example 8-13

In Example 8-13 (The account model?s addContact method), a contact object is created as follows:

var addContact = function(account, addcontact) {
contact = {
name: addcontact.name,
accountId: addcontact._id,
added: new Date(),
updated: new Date()
};

The 'name' of the contact being added (addcontact) is copied to the 'name' property of the new 'contact' object.
This name property is an object itself, composed of 'first' and 'last' Strings.

The problem is that, when saved in MongoDB, the 'name' property is not persisted. Though, the other properties, 'accountId', 'added' and 'updated', are persisted correctly.

The effect of 'name' not being persisted is a breakage in the rendering of the contact.html template, that uses 'model.name.first' and 'model.name.last'. As the 'name' property was not persisted, it is 'undefined'.

To correct this issue, I changed the definition of the 'contact' object from above to:

var addContact = function(account, addcontact) {
contact = {
name: {
first: addcontact.name.first,
last: addcontact.name.last
},
accountId: addcontact._id,
added: new Date(),
updated: new Date()
};

Then it worked!

Alexandre Aquiles  Feb 24, 2013