Git Product home page Git Product logo

express-locallibrary-tutorial's Introduction

express-locallibrary-tutorial

Tutorial "Local Library" website written in in Node/Express.


This web application creates an online catalog for a small local library, where users can browse available books and manage their accounts.

A UML diagram showing the relation of database entities in this example repository

For more information see the associated MDN tutorial home page.

Note The auth branch in this repository implements an unsupported and undocumented version of the library with User Authentication and Authorization. This may be a useful starting point for some users.

Quick Start

To get this project up and running locally on your computer:

  1. Set up a Node.js development environment.

  2. Once you have node setup install the project in the root of your clone of this repo:

    npm install
  3. Run the tutorial server, using the appropriate command line shell for your environment:

    # Linux terminal
    DEBUG=express-locallibrary-tutorial:* npm run devstart
    
    # Windows Powershell
    $ENV:DEBUG = "express-locallibrary-tutorial:*"; npm start
  4. Open a browser to http://localhost:3000/ to open the library site.

Note: The library uses a default MongoDB database hosted on MongoDB Atlas. You should use a different database for your own code experiments.

express-locallibrary-tutorial's People

Contributors

aaronmikelkey avatar andreykozhevnikov avatar assafgelber avatar benneee avatar bsmth avatar btwalpole avatar chrisdavidmills avatar columk1 avatar crn0 avatar cvoudouris avatar dependabot[bot] avatar dipikabh avatar dscotese avatar hamishwillee avatar hyfydistro avatar icehongssii avatar mozilla-github-standards avatar nitramrelpmur avatar pizzaisdavid avatar rafaelgreen1 avatar scottbowles avatar shubhamoulkar avatar truepadawan avatar vaibhavajaygupta avatar veksen avatar voloshchenkoal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

express-locallibrary-tutorial's Issues

Can't connect to MongoDB database

I am in the stage of deployment to production and decided to test my routes to check that everything still works fine just to fin out that i can no longer connect to database. I logged in to my MongoDB Atlas to see. I found out that my database is gone and trying to create another one is asking me to pay even when i chose the region with free tier.

mongo err

order of arrays appears random in populatedb.js

The following might be considered pedantic but I thought I'd bring it to your attention.

I've been following the express-locallibrary-tutorial and have got up to Part 5. I used the 'populatedb.js' script to populate a MongoDB on my local machine. I've noticed that the authors, genres and publishers are not in the same as shown in the screen shots. For instance, the "Fantasy" genre in my database has no books in it at all, but the "French Poetry" genre contains the book "The Wise Man's Fear..." plus others I suspect should be in the "Fantasy" genre. There are other "discrepancies" in the publishers and authors. I think the problem is that the "*Create" functions are called from async.parallel() but use the 'push' method to fill in the global arrays leading to a race condition, and the order of those arrays will be random. For example, "author[0]", which I think the code expects to be the "Patrick Rothfuss" entry is actually whichever call to authorCreate got to the 'push' method first. As I said this is pedantic but could lead to confusion about the correctness of code. (I at first thought it was a bug with async.parallel() not returning function results in the same order as the functions where declared in the array but on closer inspection I don't think that is the case).

Checkbox values not pulled in express from pug

In the document "Create a Book form" under "Express Web framework"
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Create_book_form

there is an error related to getting all the genre values in the express code from the form in pug

Basically, req.body.genre is supposed to return an array of selected values from the form but in the code section where req.body.genre is referenced (in the final middleware function where the new Book model instance is created), it returns only the first value stored as string. Hence the genre field always ends up saving only one value even if multiple checkboxes were ticked in the form.

when i do a console.log(req.body.genre) right before the code below it returns a string

var book = new Book(
{ title: req.body.title,
author: req.body.author,
summary: req.body.summary,
isbn: req.body.isbn,
genre: req.body.genre
});

Strangely, console.log(req.body.genre) in this code section containing the first middle ware function returns an array but the saving happens in the other function above and there it shows only one string value

(req, res, next) => {
if(!(req.body.genre instanceof Array)){
if(typeof req.body.genre==='undefined')
req.body.genre=[];
else
req.body.genre=new Array(req.body.genre);
}
next();
}

req.body.genre returns an array in the first middleware function and then in the last middleware function it returns a single value string which is the saved value for genre.

Error when trying to create home page

When using this code in BookController.js the home page stops loading:

exports.index = function(req, res) {

async.parallel({
    book_count: function(callback) {
        Book.count(callback);
    },
    book_instance_count: function(callback) {
        BookInstance.count(callback);
    },
    book_instance_available_count: function(callback) {
        BookInstance.count({status:'Available'},callback);
    },
    author_count: function(callback) {
        Author.count(callback);
    },
    genre_count: function(callback) {
        Genre.count(callback);
    },
}, function(err, results) {
    res.render('index', { title: 'Local Library Home', error: err, data: results });
});

};

Console doesn't say anything
all I get is GET/catalog/ -- ms - -

And the localhost:3000 page is just stuck in loading state

express-validator breaking behaviour between v5 and v6.

Since version 6 of express-validator:

  • Validators and sanitizers will now run in the order they are specified, instead of always running sanitizers first, then validators;

That means, that code like the following will change its behaviour:

// Handle Genre create on POST.
exports.genre_create_post =  [
   
  // Validate that the name field is not empty.
  validator.body('name', 'Genre name required').isLength({ min: 1 }).trim(),

If you just insert a space as genre-name, this will pass the express-validation, but not the Mongoose one in genre.save:

Genre validation failed: name: Path `name` is required.

Another change in behavior is by creating a new book and with multiple genres:
By sanitizing with:
sanitizeBody('*').escape(),
bookController.js#L115

it removes every genre but the first one, I think (but not sure) is because of the following breaking change:

  • non-string values will now be sanitized;

I am not sure what the best solution is: Always update the express-tutorial to be up to date to the newest versions of the npm-packages it uses or to recommend installing a fixed version?

Error: Route.get() requires a callback function but got a [object Undefined]

after adding routes/catalog.js

trace below:

/Users/dariusgoore/development/express-locallibrary-tutorial/node_modules/express/lib/router/route.js:202
        throw new Error(msg);
        ^

Error: Route.get() requires a callback function but got a [object Undefined]
    at Route.(anonymous function) [as get] (/Users/dariusgoore/development/express-locallibrary-tutorial/node_modules/express/lib/router/route.js:202:15)
    at Function.proto.(anonymous function) [as get] (/Users/dariusgoore/development/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:510:19)
    at Object.<anonymous> (/Users/dariusgoore/development/express-locallibrary-tutorial/routes/catalog.js:86:8)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/dariusgoore/development/express-locallibrary-tutorial/app.js:9:21)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
[nodemon] app crashed - waiting for file changes before starting...

Argument passed in must be a single String of 12 bytes or a string of 24 hex characters

// DISPLAY DETAIL PAGE FOR A SPECIFIC genre
exports.genre_detail = function (req, res, next) {
var id = mongoose.Types.ObjectId(req.params.id);

async.parallel({
    genre: function (callback) {
        Genre.findById(id)
            .exec(callback);
    },

    genre_books: function (callback) {
        Book.find({
                'genre': id
            })
            .exec(callback);
    },

}, function (err, results) {
    if (err) {
        console.log(req.params.id);
        return next(err);
    }
    if (results.genre == null) { // No results.
        var err = new Error('Genre not found');
        err.status = 404;
        return next(err);
    }
    // Successful, so render.
    res.render('genre_detail', {
        title: 'Genre Detail',
        genre: results.genre,
        genre_books: results.genre_books
        
    });
});

};

Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
at new ObjectID (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/bson/lib/bson/objectid.js:50:11)
at ObjectID (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/bson/lib/bson/objectid.js:31:42)
at exports.genre_detail (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/controllers/genreController.js:28:29)
at Layer.handle [as handle_request] (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/layer.js:95:5)
at next (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/layer.js:95:5)
at /home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:281:22
at param (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:354:14)
at param (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:410:3)
at next (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:275:10)
at Function.handle (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:174:3)
at router (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:47:12)
at Layer.handle [as handle_request] (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/kalleb/Documentos/projetos-javascript/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:317:13)

nested categories

Hi,

I would like to use your model as a starting point for my app. However, in my requirements there are nested categories, so if you don't mind I would ask how to implement those? For example, if your Genre would be much more complex like

โ†’ Science Fiction
โ†’โ†’ AI
โ†’โ†’โ†’ War
โ†’โ†’ Cosmos
โ†’โ†’โ†’ Interracial contact

then how do you change your model?

Book Instance functionality not working as expected.

Hello,

I am having two issues with the Book Instance functionality. I don't know if issue 1 is related to issue 2.

  1. After clicking on the All-book-instances link, the page renders as expected, but none of the books are clickable.

  2. When trying to add a new book instance, an error is thrown with the following message:

I have gone through the tutorial several times and I think the controller and views have been set-up correctly

Cast to ObjectId failed for value "undefined" at path "_id" for model "BookInstance"
CastError: Cast to ObjectId failed for value "undefined" at path "_id" for model "BookInstance"
at new CastError (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/error/cast.js:39:11)
at ObjectId.cast (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/schema/objectid.js:246:11)
at ObjectId.SchemaType.applySetters (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/schematype.js:975:12)
at ObjectId.SchemaType._castForQuery (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/schematype.js:1389:15)
at ObjectId.SchemaType.castForQuery (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/schematype.js:1379:15)
at ObjectId.SchemaType.castForQueryWrapper (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/schematype.js:1358:15)
at cast (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/cast.js:315:32)
at model.Query.Query.cast (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/query.js:4698:12)
at model.Query.Query._castConditions (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/query.js:1876:10)
at model.Query. (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/query.js:2131:8)
at model.Query._wrappedThunk [as _findOne] (/Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/mongoose/lib/helpers/query/wrapThunk.js:16:8)
at /Users/rosskinney/node-js/express-locallibrary-tutorial/node_modules/kareem/index.js:369:33
at processTicksAndRejections (internal/process/task_queues.js:75:11)

Please let me know if I can provide additional documentation for this issue.

Thanks in advance for any assistance you can provide.

Mongo DB connection using MongoClient instead of mongoose as per MongoDB docs.

I altered my project package.json using docs on MongoDB site regarding MongoClient use.
I altered both app.js and populatedb.js with the following (removing mongoose references)
//Define MongoClient
var MongoClient = require('mongodb').MongoClient
, assert = require('assert');

//Set up connection
var dev_db_url = 'mongodb://user:[email protected]:45275/library'
var mongoDB = process.env.MONGODB_URI || dev_db_url;
MongoClient.connect(dev_db_url, function(err, db) {
assert.equal(null, err);
console.log("Connected correctly to server");
});

npm/node runs these with only a warning about promise and I get the success message to console, however populatedb does not populate my db at mlabs and there is no browser url for the display of the app at localhost
, I just get the success message, obviously there is something wrong with it somewhere, does anyone know where ?
Thanks

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

author controller ; author_create_post suggestion

Hello,

First of all, thank you for this great tuto. I am still in it and I have a suggestion for the authorController.

I noticed that if one want to create a new author and fill all of the input correctly excepted one of the two dates then on submit both of the dates (the good one and the wrong one disappear).

This is because when you render the view in the author_create_post, that is the req.body that is passed to the view :

if (!errors.isEmpty()) {
            // There are errors. Render form again with sanitized values/errors messages.
            res.render('author_form', { title: 'Create Author', author: req.body, errors: errors.array() });
            return;
} 

I suggest that one should create the new author with the constructor and sanitized values before, and then pass this new author to the view as it will now contain the virtuals.

I might be wrong, plus I use EJS for the templates so maybe it may differ from the pug. If that is the case I am sorry to bother.

Thanks,

Author's name not rendering

Hello!

The author's name on the book list page does not render because the field being accessed, name, does not exist. The fields in the DB are first_name and family_name.

I will like to submit a PR, but there is no 'Contributing.md' file, how do I contribute to this project?

Deprecation warnings for express-validator

I'm getting deprecation warnings for express-validator/filter and express-validator/check:

$ DEBUG=express-locallibrary-tutorial:* npm run devstart         

> [email protected] devstart /home/user/Documents/Code/express-locallibrary-tutorial
> nodemon ./bin/www

[nodemon] 1.19.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./bin/www`
express-validator: requires to express-validator/check are deprecated.You should just use require("express-validator") instead.
express-validator: requires to express-validator/filter are deprecated.You should just use require("express-validator") instead.
  express-locallibrary-tutorial:server Listening on port 3000 +0ms

Error while running the Library app

At line:1 char:34
+ SET DEBUG=express-locallibrary:* & npm start
+                                  ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation
marks ("&") to pass it as part of a string.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmpersandNotAllowed

I am getting this error while running the app.
Please help.

Error when doing node populatedb

Hello, I'm having an issue with populating the database from part 3.

  • I added populatedb.js to my root directory
  • I ran npm install async --save in my root directory
  • Then, I ran the code below

I guessed that maybe I just had my database username put in incorrectly or the password, but I even made a second user and tried that out and it still gave me these results.

Any help is appreciated!

node populatedb mongodb://my-db-username:[email protected]:31698/local_library
This script populates some test books, authors, genres and bookinstances to your database. Specified database as argument - e.g.: populatedb mongodb://your_username:your_password@your_dabase_url
MongoDB connection error: { MongoError: Authentication failed.
    at /home/rob/express-local-library/express-locallibrary-tutorial/node_modules/mongodb-core/lib/connection/pool.js:595:61
    at authenticateStragglers (/home/rob/express-local-library/express-locallibrary-tutorial/node_modules/mongodb-core/lib/connection/pool.js:513:16)
    at Connection.messageHandler (/home/rob/express-local-library/express-locallibrary-tutorial/node_modules/mongodb-core/lib/connection/pool.js:549:5)
    at emitMessageHandler (/home/rob/express-local-library/express-locallibrary-tutorial/node_modules/mongodb-core/lib/connection/connection.js:309:10)
    at Socket.<anonymous> (/home/rob/express-local-library/express-locallibrary-tutorial/node_modules/mongodb-core/lib/connection/connection.js:452:17)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20)
  name: 'MongoError',
  message: 'Authentication failed.',
  ok: 0,
  errmsg: 'Authentication failed.',
  code: 18,
  codeName: 'AuthenticationFailed' }
(node:2616) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Authentication failed.
(node:2616) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Schema hasn't been registered for model "Genre".

My bookController.js

const book_detail = (req, res, next) => { async.parallel( { book: function(callback) { Book.findById(req.params.id) .populate("author") .populate("genre") .exec(callback); }, book_instance: function(callback) { BookInstance.find({ book: req.params.id }).exec(callback); } }, function(err, results) { if (err) { return next(err); } if (results.book == null) { // No results. var err = new Error("Book not found"); err.status = 404; return next(err); } // Successful, so render. res.render("book_detail", { title: "Title", book: results.book, book_instances: results.book_instance }); } ); };

When i go to http://localhost:3000/catalog/book/5d6bee7b04bf70aef9997566 i got error: Schema hasn't been registered for model "Genre". Use mongoose.model(name, schema)

MissingSchemaError: Schema hasn't been registered for model "Genre". Use mongoose.model(name, schema) at new MissingSchemaError (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/error/missingSchema.js:22:11) at NativeConnection.Connection.model (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/connection.js:946:11) at getModelsMapForPopulate (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js:198:59) at populate (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/model.js:4101:21) at _populate (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/model.js:4071:5) at /Users/avedemid/Projects/local-library/node_modules/mongoose/lib/model.js:4046:5 at Object.promiseOrCallback (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/utils.js:249:12) at Function.Model.populate (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/model.js:4045:16) at model.Query.Query._completeOne (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/query.js:2033:9) at Immediate.<anonymous> (/Users/avedemid/Projects/local-library/node_modules/mongoose/lib/query.js:2072:10) at Immediate.<anonymous> (/Users/avedemid/Projects/local-library/node_modules/mquery/lib/utils.js:116:16) at processImmediate (internal/timers.js:439:21)

And i really have no idea what the Genre has to do with it.

./models/genre.js file

As per instruction: This name should be required and have between 3 and 100 characters.

min max properties are missing from the model.

Stuck in Part 5: Route.get() requires a callback function but got a [object Undefined]

Hi,

I'm trying to get started with Express JS via MDN. But I stuck in part 5 / home page section.

So when I update the /controllers/bookController.js file with sample one I see these errors in terminal:

express-locallibrary-tutorial % DEBUG=express-locallibrary-tutorial:* npm run devstart

> [email protected] devstart /Users/fatihturan/Desktop/express-locallibrary-tutorial
> nodemon ./bin/www

[nodemon] 1.18.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./bin/www`
/Users/fatihturan/Desktop/express-locallibrary-tutorial/node_modules/express/lib/router/route.js:202
        throw new Error(msg);
        ^

Error: Route.get() requires a callback function but got a [object Undefined]
    at Route.(anonymous function) [as get] (/Users/fatihturan/Desktop/express-locallibrary-tutorial/node_modules/express/lib/router/route.js:202:15)
    at Function.proto.(anonymous function) [as get] (/Users/fatihturan/Desktop/express-locallibrary-tutorial/node_modules/express/lib/router/index.js:510:19)
    at Object.<anonymous> (/Users/fatihturan/Desktop/express-locallibrary-tutorial/routes/catalog.js:16:8)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/fatihturan/Desktop/express-locallibrary-tutorial/app.js:9:21)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
[nodemon] app crashed - waiting for file changes before starting...`

So where I am doing wrong?

express command does not work in git bash

Hello, I was trying to follow the local library tutorial and after installing express and running
npm install express-generator -g
All is well, but as soon as I try typing express, git bash gives me "command not found".

Heroku deployment error H10

Hello, I'm following the MDN Express Local Library tutorial, I can run run the project without any issues locally, but when I deploy it to Heroku, I always get application errors. I tinkered with the app for the whole day, but I can't find the cause for this.

My repo is here.

The errors I'm getting when I enter heroku logs --tail:

2020-09-15T18:28:25.816455+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=damp-refuge-62656.herokuapp.com request_id=88f41787-0406-4eb7-9900-4cbd48402d1a fwd="89.102.69.144" dyno= connect= service= status=503 bytes= protocol=https

2020-09-15T18:28:27.046956+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=damp-refuge-62656.herokuapp.com request_id=98d5b34c-0735-49cc-812e-7d695ebfd036 fwd="89.102.69.144" dyno= connect= service= status=503 bytes= protocol=https

Restarting/creating new dynos doesn't work. Does anyone know what I'm doing wrong? Thank you for help.

Error on bookinstance_delete_post

Hi,
I keep getting an error when I try to delete a bookinstance, specifically:

Cast to ObjectId failed for value "bookinstance._id" at path "_id" for model "BookInstance".

I checked my bookinstance model, I went through my bookinstance controller for delete_get and delete_post. Then I compared to your code and I can't seem to spot a difference. Are you getting this error as well?

Here is a link to my bookinstance controller

Update: I copied your code directly (bookinstance model and bookinstance controller) and got the same error

Populatedb.js never clarified

In the third tutorial, it is said that

You don't need to know how populatedb.js works at this point. We'll explain the relevant parts in later articles.

However, it seems that this part is forgotten.

Heroku not setting database to production

On the deployment article, I followed the steps to change database config from development to production but Heroku is still pointing to the development database. I have also verified MONGO databases, new data record is still being added to development database. Everything else works.
Please help.
Cheers

FINAL ERR : ValidationError: genre: Cast to ObjectID failed for value ....

The following error is being displayed when I run the populatedb.js file from cmd in windows :

FINAL ERR: ValidationError: genre: Cast to ObjectID failed for value "[ { _id: 5d87dcebde3ec7383840682a, name: 'Fantasy', __v: 0 } ]" at path "genre" 'w' is not recognized as an internal or external command, operable program or batch file.

The genre creation in Db is succesfull. However, if I understand properly, the genres are mapped to authors and that is the moment when the issue manifests.

Any help will be most appreciated. If needed, I could post some more details.

Thanks in advance.

i can't populate my db / Book.count() is not a function.

  1. My first error is that i can't populate my db with the populatedb.js file.
    The error that i get is "Author is not a object.

 var author = new Author(authordetail);
               ^

TypeError: Author is not a constructor
    at authorCreate (C:\Users\smook\Desktop\NewProject\express-library\populatedb.js:38:16)
    at C:\Users\smook\Desktop\NewProject\express-library\populatedb.js:112:11
    at C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:3866:24
    at eachOfArrayLike (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:1055:9)
    at eachOf (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:1103:5)
    at _parallel (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:3865:5)
    at Object.parallelLimit [as parallel] (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:3948:5)
    at createGenreAuthors (C:\Users\smook\Desktop\NewProject\express-library\populatedb.js:110:11)
    at C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:3866:24
    at replenish (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:998:17)
    at C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:1002:9
    at eachOfLimit (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:1027:24)
    at C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:1032:16
    at _parallel (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:3865:5)
    at Object.series (C:\Users\smook\Desktop\NewProject\express-library\node_modules\async\dist\async.js:4721:5)
    at Object.<anonymous> (C:\Users\smook\Desktop\NewProject\express-library\populatedb.js:212:7)

i think this is and an error in the populatedb.js file.

  1. When i try to do what they say in this article (https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data/Home_page)

I get this erro

TypeError: Book.find is not a function
   at exports.book_list (C:\Users\smook\Desktop\NewProject\express-library\controllers\bookController.js:34:10)
   at Layer.handle [as handle_request] (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\layer.js:95:5)
   at next (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\route.js:137:13)
   at Route.dispatch (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\route.js:112:3)
   at Layer.handle [as handle_request] (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\layer.js:95:5)
   at C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:281:22
   at Function.process_params (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:335:12)
   at next (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:275:10)
   at Function.handle (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:174:3)
   at router (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:47:12)
   at Layer.handle [as handle_request] (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\layer.js:95:5)
   at trim_prefix (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:317:13)
   at C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:284:7
   at Function.process_params (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:335:12)
   at next (C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:275:10)
   at C:\Users\smook\Desktop\NewProject\express-library\node_modules\express\lib\router\index.js:635:15

same thing happen with the .find() method.

My BookController file

var Book = require('../models/book');
var Author = require('../models/author');
var Genre = require('../models/genre');
var BookInstance = require('../models/bookinstance');

var async = require('async');

exports.index = function(req, res) {

    async.parallel({
        book_count: function(callback) {
            Book.count(callback);
        },
        book_instance_count: function(callback) {
            BookInstance.count(callback);
        },
        book_instance_available_count: function(callback) {
            BookInstance.count({status:'Available'},callback);
        },
        author_count: function(callback) {
            Author.count(callback);
        },
        genre_count: function(callback) {
            Genre.count(callback);
        },
    }, function(err, results) {
        res.render('index', { title: 'Local Library Home', error: err, data: results });
        console.log(err);
    });
};


// Display list of all books.
exports.book_list = function(req, res, next) {

  Book.find({}, 'title author ')
    .populate('author')
    .exec(function (err, list_books) {
      if (err) { return next(err); }
      // Successful, so render
      res.render('book_list', { title: 'Book List', book_list:  list_books});
    });

My models/book file

var mongoose = require('mongoose')

var Schema = mongoose.Schema;
var BookSchema = new Schema({
    title: {type: String, required: true},
    author: {type: Schema.ObjectId, ref: 'Author', required: true},
    summary: {type: String, required: true},
    isbn: {type: String, required: true},
    genre: [{type: Schema.ObjectId, ref: 'Genre'}]
})
//Virtual for book's url 
BookSchema  
.virtual('url')
.get(function (){
    return '/catalog/book/' + this._id
})

module.export = mongoose.model('Book', BookSchema)

I am in love with this tutorial but this error stop my learning.
And, excuse my english, please.

Thanks for read.

Where is the Part 3

Guys, do you know where to see source code for part 3?
It needs to update and I encountered unhandled rejection error.
Thanks.

Argument passed in must be a single String of 12 bytes or a string of 24 hex characters



exports.genre_detail = function(req, res, next) {
    var id = mongoose.Types.ObjectId(req.params.id); 
   
    async.parallel({
        genre: function(callback) {
            Genre.findById(id)
              .exec(callback);
        },

        genre_books: function(callback) {
            Book.find({ 'genre': id })
              .exec(callback);
        },

    }, function(err, results) {
        if (err) {
            console.log(req.params.id) 
            return next(err); }
        if (results.genre==null) { // No results.
            var err = new Error('Genre not found');
            err.status = 404;
            return next(err);
        }
        // Successful, so render
        res.render('genre_detail', { title: 'Genre Detail', genre: results.genre, genre_books: results.genre_books } );
    });
};

`





Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
    at new ObjectID (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\bson\lib\bson\objectid.js:59:11)
    at ObjectID [as ObjectId] (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\bson\lib\bson\objectid.js:40:43)
    at exports.genre_detail (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\controllers\genreController.js:20:29)
    at Layer.handle [as handle_request] (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:281:22
    at param (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:354:14)
    at param (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:365:14)
    at Function.process_params (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:410:3)
    at next (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:275:10)
    at Function.handle (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:174:3)
    at router (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:47:12)
    at Layer.handle [as handle_request] (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (C:\Users\JAYESH\Desktop\express-locallibrary-tutorial\node_modules\express\lib\router\index.js:317:13)

Update button

There seems to be an error on the MDN resource below in the book update field. The information below shows after I updated the exports.book_update_post function. I noticed there is a slight difference between the content of the function on the github repo and the function in the MDN page. The repo code works fine. Can you update the MDN page?
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/forms

body('title', 'Title must not be empty.').isLength({ min: 1 }).trim(),
^

/home/afrikhero/grive/local-library/controllers/bookController.js:250

ReferenceError: body is not defined
at Object. (/home/afrikhero/grive/local-library/controllers/bookController.js:250:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/home/afrikhero/grive/local-library/routes/catalog.js:5:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

Problem with Part 5

I am getting 0 when trying to display the number of records in the database. Please help me.
c

Unhandled promise rejection deprecation error when I run populatedb.js (Mongoose/MongoDB section)

Hello,

I was following the MongoDB/Mongoose tutorial, when I hit an error in this section. I installed async with npm and downloaded populatedb.js from the express-locallibrary-tutorial repository. With populatedb.js at the same directory level as package.json, I ran the following command from CMD on Windows 10:

node populatedb mongodb+srv://'username':'password'@cluster0-mbdj7.mongodb.net/local_library?retryWrites=true

Here are some of the error messages I received:


(node:16032) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine,
pass option { useUnifiedTopology: true } to the MongoClient constructor.

(node:16032) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a prom
ise which was not handled with .catch(). (rejection id: 1)

(node:16032) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-z
ero exit code.


Does populatedb.js need to be updated or do I need to install an earlier version of Node? My current version is 12.13.0.

Thanks.

Use of req.params.id in book_delete_post()

Hello,

In the book_delete_post() method of bookController.js, there are two cases where req.params.id is used:

Book.findById(req.params.id)

BookInstance.find({ 'book': req.params.id })

It seems to me these should both use: req.body.id

I believe the method works "as is" because the Delete button is never displayed if any book instances exist, so it doesn't matter if the Book.find and BookInstance.find fail.

Looking forward to your response.

Dave

Should API handle invalid ids/detail pages?

The locallibrary uses ids to refer to particular instances of each "thing". So for example, you can access an author like this: http://.../catalog/author/5a20cfb5cfc6cb76b0c59207. The code searches for the id, and either displays an error or renders the page.

exports.author_detail = function(req, res, next) {
    async.parallel({
        author: function(callback) {
            Author.findById(req.params.id)
              .exec(callback)
        },
        authors_books: function(callback) {
          Book.find({ 'author': req.params.id },'title summary')
          .exec(callback)
        },
    }, function(err, results) {
        if (err) { return next(err); }
        //Successful, so render
        res.render('author_detail', { title: 'Author Detail', author: results.author, author_books: results.authors_books } );
    });
};

The rub is that I just discovered that the find method above gives you an error for badly formatted queries, but returning nothing is not an error. The result being that an invalid id will just be displayed as some sort of gibberish.
Now you should never get to that sort of page unless you are manually playing with URLs. So the question for you @chrisdavidmills , is should we fix this. IMO no, but I figured I'd ask -)

If we were to fix this, then there are several options. The first is just to check this case and redirect to the normal error page:

    }, function(err, results) {
        if (err) { return next(err); }
        //Successful, so render
        if (results.author==null) {
            var err = new Error('Author Not Found');
            err.status = 404;
            next(err);
        }
        else {
            res.render('author_detail', { title: 'Author Detail', author: results.author, author_books: results.authors_books } );
        }

Alternative is to render a custom 404 page. I'd prefer to simply treat this as an error. This is supposed to be simple :-)

error on heroku deployment, ..models/bookinstance not found

I am having a successful build, yet when I enter heroku open, the deployment fails. Here is the push to heroku master...

Counting objects: 59, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (59/59), done.
Writing objects: 100% (59/59), 23.12 KiB | 0 bytes/s, done.
Total 59 (delta 42), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.9.3
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 8.9.3...
remote: Downloading and installing node 8.9.3...
remote: Using default npm version: 5.5.1
remote:
remote: -----> Restoring cache
remote: Loading 2 from cacheDirectories (default):
remote: - node_modules
remote: - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: added 73 packages, removed 106 packages and updated 13 packages in 5.203s
remote:
remote: -----> Caching build
remote: Clearing previous node cache
remote: Saving 2 cacheDirectories (default):
remote: - node_modules
remote: - bower_components (nothing to cache)
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote: Done: 21.3M
remote: -----> Launching...
remote: Released v6
remote: https://calm-everglades-12109.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/calm-everglades-12109.git
da1f479..9c81077 master -> master

Here are the heroku logs from command line https://gist.github.com/MadRiver44/853fa6a27379c43a0ae5debd841787f7

Why is it not finding the ..models/bookinstance?
The steps I've taken are: check and compare code, check package.json, looked for typos, check all requires, all models and controllers, and tested locally ---which works fine, and read heroku troubleshooting node.js apps

What's the use of the callbacks in async.parallel member functions ?

So, I understand that when you have multiple functions that need to be called asynchronously, we use async.parallel and pass an array or object of functions.

But inside these functions( inside the object of functions), a 'callback' argument is passed and then just passed to exec function.

What is this 'callback' argument ? Where does it come from ? How is it necessary ?

mdn reference

// Display detail page for a specific Genre.
exports.genre_detail = function(req, res, next) {

    async.parallel({
        genre: function(callback) {
            Genre.findById(req.params.id)
              .exec(callback);
        },

        genre_books: function(callback) {
            Book.find({ 'genre': req.params.id })
              .exec(callback);
        },

    }, function(err, results) {
        if (err) { return next(err); }
        if (results.genre==null) { // No results.
            var err = new Error('Genre not found');
            err.status = 404;
            return next(err);
        }
        // Successful, so render
        res.render('genre_detail', { title: 'Genre Detail', genre: results.genre, genre_books: results.genre_books } );
    });

};

forum for troubleshooting?

is there a forum for troubleshooting or a repo for the completed tutorial? (other than stackexchange?)
for that matter, is there a repo with the completed project to compare with.


currently experiencing an error while on the Book_detail_page. probably obvious, thrown me for the moment.

Schema hasn't been registered for model "Genre". Use mongoose.model(name, schema)

my current commit.

https://github.com/aspiringguru/mdn_express_nodejs_skeleton/tree/c347992765fadebe7af233c0f03ef222cbf4803f

on this page of the tutorial.
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data/Book_detail_page

Please review naming conventions

This is not a coding issue - it more to do with making the otherwise excellent tutorial easier to comprehend. As someone new to Javascript I cannot easily understand the coding examples when you use the same word to describe many similar things. For example you use 'author' to be both a file name and a document name - so by using 'author' in the the following code it really does not illustrate when to use each instance of 'author':

_for author in authors
if book
option(value=author._id selected=(author._id.toString()==book.author._id.toString() ? 'selected' : false) ) #{author.name}
else
option(value=author.id) #{author.name}

If you had used 'people' for one and 'author_id' for the other it would make understanding so much easier. The same goes for 'genre', which can also used to mean two completely different things in the same command line.

I have had similar difficulties when variables/functions are given names that could easily be Javascript commands - as it is not always apparent what words/terms you are demonstrating, and which ones are simply made up.

Otherwise I have found this tutorial very useful and thank you for giving up your time to produce it.

minor issues due to current versions of packages.

Recently completed the tutorial, minor issues found due to current package versions deprecated methods used in the tutorial. Not essential to use these updates below.

from app.js

mongoose.connect(mongoDB, { useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex: true }); 

in any of the controllers using express-validator, deprecation errors will result if using

require('express-validator/check'); or require('express-validator/filter');

use

require('express-validator'); 

instead.

const { body,validationResult } = require('express-validator');
const { sanitizeBody } = require('express-validator');

npm run serverstart not working on Windows

i am following the tutorial but i get errors when i try npm run serverstart.

when i change

  "scripts": {
    "start": "node ./bin/www",
    "devstart": "nodemon ./bin/www",
    "serverstart": "DEBUG=express-locallibrary-tutorial:* npm run devstart"
  }, 

with

  "scripts": {
    "start": "node ./bin/www",
    "devstart": "nodemon ./bin/www",
    "serverstart": "set DEBUG=express-locallibrary-tutorial:* | npm run devstart"
  },

and run
npm run serverstart
then i get no errors but i dont know if this is correct

req.checkBody(...).optional(...).isDate is not a function

Hi, I'm trying to learn Express framework by doing your tutorial ( https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/forms ) and encounter a problem. Whenever I submit a form that uses .isDate() validator (from express-validator module), I get the following error:

TypeError: req.checkBody(...).optional(...).isDate is not a function
    at exports.author_create_post (/Users/w/webhome/node/express-locallibrary-tutorial/controllers/authorController.js:50:83)

The only differences between my code and mdn's code are the dependencies versions of some modules:

"dependencies": {
    [...],
    "express": "~4.15.5",
    "express-validator": "^4.2.1",
    [...]
  },

in my package.json but

"dependencies": {
    [...],
    "express": "~4.14.0,
    "express-validator": "^3.0.0",
    [...]
  },

in mdn's package.json. The modules have been added by doing npm install <module_name> --save, as suggested in the tutorial.

We can reproduce the issue by cloning mdn's repository and changing the modules mentioned by more recent versions.

express-validator say their rewrite from 3.x to 4.x is backwards compatible
https://github.com/ctavan/express-validator/releases

Thank you very much for your help!

Cardinality on UML diagram on readme and docs is wrong/opposite

So for example a book can have 0 or more bookinstance, and a bookinstance must have exactly one book. When I learned UML the cardinality was shown as I have done so in the images, but it appears the spec now has them the other way.

Don't have time to fix right now, so this is a TODO note.

Getting the following errors when i am trying to run node populate mongodb

DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
MongoDB connection error: { MongoNetworkError: failed to connect to server [ds121183.mlab.com:21183] on first connect [MongoNetworkError: connect ETIMEDOUT 52.90.44.246:21183]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.