课程: Databases for Node.js Developers (2021)
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Implement all database methods
- [Tutor] After lots of preparation, we are finally ready to implement the service that is responsible for all the database logic for items. Put it I'm in server services, itemService. I start with first bring in the model that we created before. So add const itemModel equals require and it's one level up, models, mongoose and there. It's called item. Next let's start with implementing a class to class, should be named class ItemService. And in the end, just add module.exports equals itemService, so that we don't forget that. So itemService will just contain static methods. This means we will only call methods on the class itself and never on the instance. So I start with adding static async, maybe you remember, we need a getAll method that gives us all items that we have in the catalog. So here I now return, and that's really easy now with the model mongoose gives us ItemModel.find. And here I put in curly brackets,…
内容
-
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-
-
-