O'Reilly logo

Node.js Blueprints by Krasimir Tsonev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with the database

In Chapter 3, Writing a Blog Application with Node.js and AngularJS, we used MongoDB and MySQL. We learned how to read, write, edit, and delete records from these databases. Let's use MongoDB in this chapter, too. We will store our data in a collection named books. To use the database driver, we need to create a package.json file and put the following content in it:

{
  "name": "projectname",
  "description": "description",
  "version": "0.0.1",
  "dependencies": {
    "mongodb": "1.3.20"
    "request": "2.34.0"

  }
}

After running npm install, we will be able to connect to the MongoDB server by using the driver installed in the node_modules directory. The code that we need to interact with the database is the same as the one used in Chapter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required