课程: Vue.js: Creating and Hosting a Full-Stack Site
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Loading individual products from MongoDB
课程: Vue.js: Creating and Hosting a Full-Stack Site
Loading individual products from MongoDB
- Alright, so we've added MongoDB to two of our three load endpoints. So the last thing that we're going to do here is see how to add MongoDB to our endpoint for loading individual product data. So what this is going to look like it's going to be very similar to what we've seen elsewhere. We're going to start off by connecting to MongoDB and selecting the database. So I'm just going to copy those lines from our cart endpoint and paste them inside here. And then of course, we're also going to need to add the async keyword to our callback function. And now that we've done that, what we're going to do is after we get the product ID from the URL parameter instead of finding the product in our array which was the old way of doing things when we were still storing our database in a file, we're going to say const product equals and then we'll say await db.collections. And that's going to be product and actually it's not…
内容
-
-
-
-
-
(已锁定)
Why MongoDB?1 分钟 4 秒
-
(已锁定)
Setting up MongoDB6 分钟 13 秒
-
(已锁定)
Connecting and adding data to MongoDB7 分钟 42 秒
-
(已锁定)
Adding MongoDB to a Node.js server7 分钟 14 秒
-
(已锁定)
Adding MongoDB to GET endpoints6 分钟 53 秒
-
(已锁定)
Loading individual products from MongoDB4 分钟 53 秒
-
(已锁定)
Creating data in MongoDB5 分钟 54 秒
-
(已锁定)
Deleting data in MongoDB4 分钟 10 秒
-
(已锁定)
-
-
-
-