Mongoose lets you define models to provide a schema for your data. In this video, learn how you can create a schema for shop items and how to use it from your Express routes.
- [Instructor] As mentioned before, Mongoose relies…on models that define documents.…We want to Mongoose for our item management…and so we have to create an item model.…I've prepared the directory structure for that ready…so you should find in server models, Mongoose,…a file called item, let's open that.…And here we go now at our model to finish it.…I will close the left menu bar here so we have a little…bit more space and I add const mongoose equals…require ('mongoose') enter and now define the schema…so I started const, ItemSchema equals mongoose.Schema…and round brackets.…
In there we add curly brackets because we want to pass…in a java script object here.…And in there, we define some fields that our item…documents should have.…So for instance, sku makes sense.…So the item number and it should be the type, number.…It should be required, so I add required true…because there should be no item without the sku…and there should be an index and this index…should be unique because most probably in some…shopping system, an item number should only exist once.…
- 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
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.