Scott walks through a more complex schema definition to introduce all the different data types that can be used when defining properties. These data types include Boolean, String, Number, Date, and Buffer. Scott also talks about nested objects and additional validation rules like min and max.
(traditional flute with heavy bass)…- So, above is a small example of a schema with Mongoose,…but those are the basics.…Here is a tour of a whole bunch of other types…we can use in the schema.…So, this time we're going to make a dog schema.…Alright, same thing, new, mongoose, schema.…Here we have a name for the dog, its type is string.…It's also required.…And we also want to enforce that it be unique.…So there can be no two dogs with the same name.…So if we tried to save a dog with a name,…whose type was string,…but then there already existed one with that same name,…with the same string,…it'll throw a validation error, or unique error.…
Unique also accounts for no values too.…But because we put required true,…we probably won't run into that error.…You will have that error…if you didn't put required true here,…but you put unique true,…and the first dog you save didn't have a name,…because it's not required,…the next dog you save didn't have a name,…it'll throw a validation error,…because you already have one dog who doesn't have a name,…
This course was created by Frontend Masters. It was originally released on 12/30/2015. We're pleased to host this training in our library.
- Executing Node.js
- Using Express
- What is middleware?
- Testing in Node.js
- Using Mongo with Node.js
- Data modeling
- Querying data with Mongoose
- Identifying sensitive routes
- Configuring the deployment
Skill Level Intermediate
Node.js: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
Node.js: Extend and Maintain Applicationswith Daniel Khan3h 35m Intermediate
2. REST APIs
5. Organization and Configuration
7. Data Modeling
10. Securing Routes
- 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.