Nodejs create read update delete operations with angular, mongodb and expressjs part-1

What is nodejs?
-> Node.js is a server-side platform built on Google Chrome’s JavaScript Engine (V8 Engine). Node.js was developed by Ryan Dahl in 2009.

Node.js is an open source, cross-platform runtime environment for developing server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, and Linux.

Node.js also provides a rich library of various JavaScript modules which simplifies the development of web applications using Node.js to a great extent.

Feature of this app

  • Read records from mongodb using node js and show uisng angularjs
  • Insert record in mongo db using node js api call.
  • Image upload using apis call
  • Batch delete records.
  • Restfull architecture

After finish this tutorial we will be able to see app like this

Listing movies

https://i1.wp.com/webrocom.net/wp-content/uploads/2016/10/FireShot-Capture-1-Vidzy-App-http___localhost_vidzyApp__.png

Add Movie

https://i1.wp.com/webrocom.net/wp-content/uploads/2016/10/FireShot-Capture-3-Vidzy-App-http___localhost_vidzyApp__create.png

Remove Record

https://i1.wp.com/webrocom.net/wp-content/uploads/2016/10/FireShot-Capture-4-Vidzy-App-http___localhost_vidzyApp__video_delete_580e5b1e062cbe242a000001.png

Batch Delete

https://i1.wp.com/webrocom.net/wp-content/uploads/2016/10/FireShot-Capture-6-Vidzy-App-http___localhost_vidzyApp__.png

Directory structure

We have two folder for this app. One for frontend and second for backend for apis.

Root–
———-Frontend
—-Angular js app structure
—–app(app js file and another important js files)
—–node_modules(npm installer essentials modules)
—–view(html files)
—–Index.html(Main entry view)
———-Backend
—-Express js structure

Expressjs

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

We need to install expressjs in backend folder so move to backend folder on your terminal and type following command

$ npm install express --save

This command will install express

We can use Express application generator for quickly create an application skeleton.

So run this command under the Backend folder

$ express myapp

It will create directory structure like this:
.
├── app.js
├── bin
│ └── www
├── package.json
├── public
│ ├── images
│ ├── javascripts
│ └── stylesheets
│ └── style.css
├── routes
│ ├── index.js
│ └── users.js
└── views
├── error.jade
├── index.jade
└── layout.jade

7 directories, 9 files

Just type Cut all files under myapp folder and paste all files in backend folder. So Your backend folder structure should be look like this

Backend
——– .
├── app.js
├── bin
│ └── www
├── package.json
├── public
│ ├── images
│ ├── javascripts
│ └── stylesheets
│ └── style.css
├── routes
│ ├── index.js
│ └── users.js
└── views
├── error.jade
├── index.jade
└── layout.jade

Conclusion

We in this article we have created simple directory structure for our Movies list CRUD project
using express js node framework.
In the next tutorial we will create apis endpoint for create, read, update, delete operations.

Contact for PHP Mysql, Codeigniter, Laravel, symfony, NodeJS, AngularJS, ReactJS training in mumbai.
Weekend Classes available.
Call me on 9022349606.

Team Webrocom.