In this video, learn how to create a service model that creates orders from a shopping basket.
- [Instructor] Until now we just have a service…that loads a model.…Next we will create the service functions needed…to store an order.…We talked about transactions before, and we want…to make sure that the database stays in a…consistent state if something went wrong.…For instance, if we already created the order…and the order item entries, but deleting from the…basket in Reddit fields, we want to rollback everything.…What we now need is a way to use my sequel…or sequelized transactions to also trigger a rollback…if something outside of our service method fails.…
For that we will create a little,…but sophisticated, helper function.…So I open server services orderService.js.…And here I start implementing a function.…It's async function inTransaction.…And this function gets a parameter called work.…This is the work item that should be run…inside this transaction.…
Next we will create the transaction.…So I add const t = await client.transation,…brackets because it's a function.…Next we will add a try catch block, so I start with try.…
- 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: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
Building a Website with Node.js and Express.jswith Ray Villalobos3h 16m 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.