Let's start with understanding what is MVC
M - Model (Involves Databases, and rules)
V - View (It is the design and visual aspect)
C - Controller (It connects model and view via logic)
MVC is a software design pattern that helps us to structure the code into models, controllers, and views hence improving the code structure and readability.
Sails JS is an MVC framework for nodeJS, it is built on the top of node js and express Js so all that is applicable in NodeJS and express will work with sails JS.
Today we will make a Books app
Please make sure you have node js and sails js installed [Installation]
Initialise the sails project using
sails new books-app
Choose empty project in the console(2)
lets now quickly install all the dependencies
npm i mongodb mongoose
Go inside config/models.js uncomment migrate: ‘alter’ and replace alter with safe. Alter will drop the schema everytime we restart the server which we do not want.
Create a new file called mongoose.js inside config folder
We will create our db connection using from this file…
Sails JS is a MVC framework for node JS built on top of Node and express JS. It provides allows you to quickly get started with the REST API’s.
Lets get step up a sails js project quickly to get you familiar with the framework.
Open up your favourite Terminal/command Prompt. I am using visual studio on ubuntu 20.04
Go to your preferred location, here I will choose Desktop/medium
cd Desktopmkdir mediumcd medium
I write articles to share my experiences with technologies :)