Black Friday is here! Take advantage of this unique opportunity and get up to 80% extra knowledge for free! Read more here
bf extended_2022

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.

Limited offer: Learn all knowledge and save money

Buy lessons and exercise submitting one by one $5.76
Buy all currently available lessons with exercise submitting and other features for an exclusive price $4.86
Currently, you have $0
By buying this exclusive package, you'll have access to all 9 lessons in this course including exercise submitting while saving $0.90. This offer is limited for the first lessons only with an additional exclusive 15% discount.

Warning, by buying just this lesson you'll lose the limited 15% discount for the package of all the lessons.

Buy only the lesson $1.44
Currently, you have $0

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