Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Full stack web development Course | 115. SWAG SHOP API: CREATING MODELS
Play lesson

Full Stack Web Development Tutorial Course - Full stack web development Course | 115. SWAG SHOP API: CREATING MODELS

4.0 (3)
36 learners

What you'll learn

This course includes

  • 26.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

Full-stack web development Tutorial in Just 3 Weeks Week 3: Day 2 Section 12: Intro to Node, Mongo, & REST APIs Tutorial 115: Swag Shop API: Creating the Models In this video tutorial, we are going to create a model that defines the data we are gonna store. Models are constructors compiled from schema definitions. An instance of a model is called a document. Models are responsible for creating and reading documents from the MongoDB database. Compiling your first model When you call mongoose.model() on a schema, mongoose compiles model for you. In this video for example: Var mongoose= require( 'mongoose'); Var schema=mongoose. Schema; Var product = new schema({ Title: string, Price: number, Likes:number;}) Module.exports=mongoose. Model('Product',product); The Model() function makes a copy of a schema. Make sure to add everything into the schema before calling .model(). Constructing documents An instance of the model is known as a document. It’s easy to create and store a document in the database. Querying Using the query syntax of MongoDB we can easily find documents in mongoose. Find, FindOne, where are some of the static methods used. Deleting DeleteOne() and deleteMany() are used for deleting documents. Updating Update() is used to modify any document.

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere