Posts

Showing posts with the label express.js

How to Use Sequelize ORM In Node

Image
Prerequisites Node MySql What Is Sequelize? As mentioned on the sequelize site, sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication and more. Sequelize follows  SEMVER . It supports Node v6 and above to use ES6 features. Project Structure  |---------  config                |--------- db.js |--------- controllers                |--------- memberController.js |--------- models                |--------- member.js |--------- routes                |-------- members.js |--------- views                 | |------- partials                 |              |------- header.ejs                 |              |------- footer.ejs                 |                 |------ home.ejs                 |------ edit.ejs |---------  app.js |--------- package.json Project Setup Le

CURD operations in node.

Image
Image by StartupStockPhotos from Pixabay Setup Node On System    If you dont have node installed on your system then you can download it   click here After installing the node on system.Open cmd and type node-v .It will give node version like this        Setup MongoDB On System  If you dont have mongodb installed on your system then you can download it from  here    Follow the installation instruction given there.   Now setup our node project  Open cmd type mkdir and give directory name. Now your directory to that using cd directory name which we created.  Now type npm init -y . this will make a package.json file in your folder. Now we will npm  install package which we will use in our project.And all these will be shown in package.json. The npm packages we will install here are express,mongoose,body-parser,ejs.          This is how package.json looks               A little info about packages we using body-parser will contain