MCV
A design pattern for the ages. Model-View-Control takes the 'separation of concerns' ideology you are already familiar with in JavaScript, and applies it app wide.

Hold the phone...
What are we even separating?

-
MVC decouples the visual representation (view) from the business logic (model)
-
With clear guidelines set, whenever an update happens to the application it is easier to see whether the changes are data driven or merely visual.
-
Maintenance and scalability are now achievable from the get go.
View
Let's start with you

BUT HOLD UP

Who is gonna hold my hand on my way to the website?
It's time to route, baby
When the browser requests data, the router must determine if that path even exists. If it does, move forward!

Becky, look at her database..
Views are simply a visual representation of a model's (database's) current state.

The user can input data using the http request, which gets passed to the controller who then decides what view to render for the browser, along with any appropriate data if needed.
Controller
"This handles user interaction by interpreting mouse clicks and keyboard inputs the user does, informing model and view to change appropriately."

So basically
When you type or click to modify information on a website, the controller tells this info to the database, and the database tells the controller the updated information, and the controller tells the view what to render for the user.

With that said, we now understand a bit about model, which does the following:
- Receives/stores information from the controller
- Notifies its observers (View) of change to the data
- Takes care of business...data. Not concerned about the looks of the page at all.
Now, it's Mongoose time

Modeling application data with a schema based solution!

It is a blueprint.
We are builders. Builders use blueprints to map out how something is going to be constructed. Mongoose is our design framework for our database.

Object Data Modeling (ODM)
Mongoose is a library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB.

In other words..
Mongoose allows us to make an object looking data structure that we export and use in our application. It allows for easy connection to our database.

deck
By Ryan Booth
deck
- 37