Get up to 80 % extra points for free! More info:

Lesson 7 - Reading Data From MongoDB, RESTful API with a database

In the previous lesson, First steps in MongoDB, we showed how to create MongoDB schemas and compile them into models. We also learned how to create new documents in a collection and how to return all documents from the collection. Today we're going to continue, learn advanced search for collection items and start refactoring our RESTful API in Node.js from past lessons to make it work with the database.

Selecting a Document by ID

MongoDB prepares an _id item for each entry automatically. We can consider this item as the unique identifier of the record , ie. it'll always occur in the collection only once. Another advantage is that this item serves as an index (similar to the primary key in relational databases) and we can search by it very fast. Therefore it's a good idea to use it as much as possible, it's useful almost every time we work with a single record.

There are the following methods on the


 

...End of the preview...
Continue further

You will gain knowledge worth hundreds of thousands for a few crowns

You've come here and that's great! We believe that the first lessons showed you something new and useful
Do you want to continue the course? Go to the premium section.

Buy this course

Buy all currently available lessons with exercise submitting and other features for just $5.76
Current account balance $0
By buying this package, you'll have access to all 9 articles (9 lessons) in this course.

This article is licensed: Premium II, by buying this article, you agree with the terms of use.

What will you get from us in the next lessons?
  • Unlimited and permanent access to individual lessons.
  • High quality IT knowledge.
  • Skills to help you get your dream and well-paid job.

Article description

Requested article covers this content:

This tutorial shows what MongoDB offers when reading data and how to use it. The first part of the RESTful API with MongoDB is also implemented in Node.js.

You gain credits by supporting our network. This is done by sending a helpful amount of money to support the site, or by creating content for the network.

Article has been written for you by Radek Veverka
Avatar
Activities