In this video, Daniel shows you how to query data from MongoDb with Node.js.
- [Instructor] So now that we have…inserted all this data into MongoDB,…we also want to query it.…So now let's implement the query for that.…I want to select the maximum bitcoin value…from MongoDB, and this can be simply done…by using findOne, which will return the first result…from the result set, and sorting this whole query…by bitcoin value descending…because then the very first item…will be the highest value of this.…
So for that have to define some query options,…const options…equals…and then curly brackets,…and there I want to define sort.…And we sort by,…and there you have to use this double square brackets,…value, and we want…to do it in descending order…so that the highest value…is on top of the result set.…
Now we have to do the actual query.…So I add collection.findOne,…and we don't add any special query in here…because we want to have all data sets,…but we will pass in the options…for the sorting, and then here we can use promises…or a callback as well.…I will use a callback now.…It's really a matter of taste.…
- Basics of relational and nonrelational databases
- Preparing your environment
- When to use document databases
- Inserting data into MongoDB
- Basic insert operations for MongoDB
- Querying data from MongoDB with Node.js
- Using key-value stores
- Using relational databases with Node.js
- Adding MySQL and Sequelize to a project
Skill Level Intermediate
Node.js: Extend and Maintain Applicationswith Daniel Khan3h 35m Intermediate
Node.js: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
1. Get Started with Databases for Node.js
2. Prepare Your Environment
3. Use Document Databases with Node.js
4. Use Key-Value Stores with Node.js
5. Use Relational Databases with Node.js
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.