课程: Databases for Node.js Developers (2021)
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Query data from MongoDB
- [Trainer] Finally let's implement the logic that will fetch the maximum value and its state from the database. For that, I will scroll down to the getMax method. So how can we get the maximum value? The most efficient way in MongoDB is actually by using sorting. This means I will vary the database, sort by the value in descending order, and then get just one element from it which is then naturally of course, the highest value and this can achieved but just one line of code. So I return this.ollection, and on collection there is this method findOne which will return exactly one document and here I would have the queries. So if I want to find one specific document I would have the very year, but in our case we want to query all documents, but then a second argument I can pass in options and in our case I will pass in sort and I want to sort by value and to make it in descending order, I add colon minus one. So…
内容
-
-
-
-
-
(已锁定)
When to use and not to use document databases2 分钟 11 秒
-
(已锁定)
Set up MongoDB4 分钟 39 秒
-
(已锁定)
Connect to MongoDB13 分钟 54 秒
-
(已锁定)
Insert data into MongoDB6 分钟 43 秒
-
(已锁定)
Query data from MongoDB4 分钟 41 秒
-
(已锁定)
Introduction to Mongoose9 分钟 24 秒
-
(已锁定)
Add MongoDB and Mongoose to your project5 分钟 57 秒
-
(已锁定)
Define your first schema and model3 分钟 50 秒
-
(已锁定)
Prepare the item management system6 分钟 4 秒
-
(已锁定)
Implement all database methods7 分钟 48 秒
-
(已锁定)
Implement the user management system7 分钟 26 秒
-
(已锁定)
Encrypting passwords4 分钟 40 秒
-
(已锁定)
-
-
-