concept MongoDB database in category angular

appears as: MongoDB database
Getting MEAN with Mongo, Express, Angular, and Node.js 2ED

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.

MongoDB sets itself apart from many other document databases with its support for secondary indexing and rich queries. You can create indexes on more than the unique identifier field, and querying indexed fields is much faster. You can also create some fairly complex queries against a MongoDB database—not to the level of huge SQL commands with joins all over the place, but powerful enough for most use cases.

You’ll start by connecting your application to a database before using Mongoose to define schemas and models. When you’re happy with the structure, you can add some test data directly to the MongoDB database. The final step is making sure that access to the data store also works when pushed up to Heroku. Figure 5.2 shows the flow of these four steps.

Figure 5.3. Viewing the MongoDB database and using Mongoose inside Express to model the data and manage the connection to the database

You’ll be working with a MongoDB database, but most of the work will be in Express and Node. In chapter 2, we discussed the benefits of decoupling the data integration by creating an API rather than tightly integrating data into the main Express app. Although you’ll be working in Express and Node and still within the same encapsulating application, you’ll be starting the foundations of your API layer.

5.4.2. Creating a MongoDB database

You don’t have to create a MongoDB database; you only need to start using it. For the Loc8r application, it makes sense to have a database called Loc8r. In the shell, you use it with the following command: