‫So, we connected our application
‫with the database using Mongoose in the last lecture.
‫But wait, what actually is Mongoose?
‫Well, Mongoose is an object data modeling library
‫for MongoDB and Node JS,
‫providing a higher level of abstraction.
‫So, it's a bit like the relationship
‫between Express and Node,
‫so Express is a layer of abstraction over regular Node,
‫while Mongoose is a layer of abstraction
‫over the regular MongoDB driver.
‫And by the way, an object data modeling library
‫is just a way for us to write JavaScript code
‫that will then interact with a database.
‫So, we could just use a regular MongoDB driver
‫to access our database, and it would work just fine,
‫but instead we use Mongoose,
‫because it gives us a lot more functionality out of the box,
‫allowing for faster and simpler development
‫of our applications.
‫So, some of the features Mongoose give us
‫is schemas to model our data and relationship,
‫easy data validation, a simple query API,
‫middleware, and much more.
‫In Mongoose, a schema is where we model our data,
‫so where we describe the structure of the data,
‫default values, and validation.
‫We then take that schema and create a model out of it.
‫And the model is basically a wrapper
‫around the schema, which allows us to actually interface
‫with the database in order to create, delete, update,
‫and read documents.
‫All right, so this was just a very quick introduction.
‫Now, let's actually go ahead
‫and create a simple schema and model.