Posts

Showing posts with the label express.js

How to Use Sequelize ORM in Node.js with Express & MySQL

Prerequisites Node.js MySQL What Is Sequelize? 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 and supports Node v6 and above to utilize ES6 features. Express and Sequelize 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 Let's begin by setting up our workspace: Open the console and type mkdir followed by your directory name. ...

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 pack...