SlideShare a Scribd company logo
2
Most read
Stack RESTful API Tutorial - Using MongoDB, Express,
Angular JS, and Node JS Together
Before starting on these let us discuss about the platforms terms.
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 and its
latest version is v0.10.36. The definition of Node.js as supplied by its official
documentation is as follows −
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast and
scalable network applications. Node.js uses an event-driven, non-blocking I/O model
that makes it lightweight and efficient, perfect for data-intensive real-time applications
that run across distributed devices.
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.
Node.js = Runtime Environment + JavaScript Library
Features of Node.js
Following are some of the important features that make Node.js the first
choice of software architects.
∑ Asynchronous and Event Driven All APIs of Node.js library are asynchronous
that is, non-blocking. It essentially means a Node.js based server never waits
for an API to return data. The server moves to the next API after calling it and a
notification mechanism of Events of Node.js helps the server to get a response
from the previous API call.
∑ Very Fast Being built on Google Chrome's V8 JavaScript Engine, Node.js library
is very fast in code execution.
∑ Single Threaded but Highly Scalable - Node.js uses a single threaded model
with event looping. Event mechanism helps the server to respond in a non-
blocking way and makes the server highly scalable as opposed to traditional
servers which create limited threads to handle requests. Node.js uses a single
threaded program and the same program can provide service to a much larger
number of requests than traditional servers like Apache HTTP Server.
∑ No Buffering - Node.js applications never buffer any data. These applications
simply output the data in chunks.
∑ License - Node.js is released under the MIT license.
Who Uses Node.js?
Following is the link on github wiki containing an exhaustive list of projects,
application and companies which are using Node.js. This list includes eBay,
General Electric, GoDaddy, Microsoft, PayPal, Uber, Wikipins, Yahoo!, and
Yammer to name a few.
∑ Projects, Applications, and Companies Using Node
Concepts
The following diagram depicts some important parts of Node.js which we
will discuss in detail in the subsequent chapters.
Where to Use Node.js?
Following are the areas where Node.js is proving itself as a perfect
technology partner.
∑ I/O bound Applications
∑ Data Streaming Applications
∑ Data Intensive Real time Applications (DIRT)
∑ JSON APIs based Applications
∑ Single Page Applications
Where Not to Use Node.js?
It is not advisable to use Node.js for CPU intensive applications.
What is MongoDb?
MongoDb is a Open Source database written in C++.
Drivers and client libraries are typically written in their respective languages,
although some drivers use C extensions for better performance.
If the load increases, by adding more nodes (such as a computer), the
performance can be retained.
It can be used to store data for very high performance applications (for example
Foursquare is using it in production).
MongoDB does not support SQL It supports a rich, ad-hoc query language of its
own.
MongoDb stores data as documents. So it is a document oriented database.
FirstName="Arun", Address="St. Xavier's Road", Spouse=[{Name:"Kiran"}],
Children=[{Name:"Rihit", Age:8}].
FirstName="Sameer",Address="8 Gandhi Road".
Notice there are two different documents (separated by "."). Storing data in this
fashion is called asdocument oriented database. MongoDb is a document
oriented database.
Key Features
Since MongoDb offers a Document oriented storage, It is simple and easily
programmable.
∑ You can set an index on any attribute of a MongoDb record (as
FirstName="Sameer",Address="8 Gandhi Road"), with respect to which, a record can be sort
quickly and ordered.
∑ You can set mirror across local as well as wide area networks, which makes it easily scalable.
∑ If load increases (more storage space, more processing power), it can be distributed to other
nodes across computer networks. This is called as sharding.
∑ MongoDb supports rich query to fetch data from the database.
∑ MongoDb supports replacing an entire document (database) or some specific fields with it's
update() command.
∑ MongoDb supports Map/Reduce framework for batch processing of data and aggregation
operation. Here is brief of how Map/Reduce works :
∑ Map : A master node takes an input. Splits it into smaller sections. Sends it to the associated
nodes.
∑ These nodes may perform the same operation in turn to send those smaller section of input to
other nodes. It process the problem (taken as input) and sends it back to the Master Node.
∑ Reduce : The master node aggregates those results to find the output.
∑ GridFS specification of MongoDb supports storage of very large files.
∑ MongoDb supports various programming languages like C, C# and .NET, C++, Erlang, Haskell,
Java, Javascript, Perl, PHP, Python, Ruby, Scala (via Casbah).
∑ It supports Server-side JavaScript execution. Which allows a developer to use a single
programming language for both client and server side code.
∑ MongoDb is easily installable.
MongoDB Fundamentals : Frequently Asked Questions
What kind of database is MongoDB?
MongoDB is a document-oriented DBMS. Think of MySQL but with JSON-like
objects comprising the data mode, rather than RDBMS tables. MongoDB
supports neither joins nor transactions.
Do MongoDB database stores its data in tables?
A MongoDB database stores its data in collections instead of tables, which are
the rough equivalent of RDBMS tables.
Do MongoDB databases have schemas?
MongoDB uses dynamic schemas. Without defining the structure you can create
collections, i.e. the fields or the types of their values, of the documents in the
collection. You can change the structure of documents simply by adding new
fields or deleting existing ones.
Which programming languages can be used to work with MongoDB?
MongoDB client drivers exist for all of the most popular programming languages.
See the latest list of drivers for details.
Does MongoDB support SQL?
No.
What are typical uses for MongoDB?
Content management systems, mobile applications, gaming, e-commerce,
analytics, archiving, and logging.
Does MongoDB support transactions?
No. However, MongoDB does provide atomic operations on a single document.
Does MongoDB require a lot of RAM?
Not necessarily. It's certainly possible to run MongoDB on a machine with a small
amount of free RAM. MongoDB automatically uses all free memory on the
machine as its cache.
Does MongoDB handle caching?
Yes. MongoDB keeps all of the most recently used data in RAM. If you have
created indexes for your queries and your working data set fits in RAM,
MongoDB serves all queries from memory.
What are the limitations of 32-bit versions of MongoDB?
Changed in version 3.0: Commercial support is no longer provided for MongoDB
on 32-bit platforms (Linux and Windows).
History
Development of MongoDB began in October 2007 by 10gen. The first public
release was in February 2009.
Obtain MongoDb
You can download MongoDb from http://www.mongodb.org/downloads. As of this
writing, it supports following platforms:
∑ OS X 32-bit
∑ OS X 64-bit
∑ Linux 32-bit
∑ Linux 64-bit
∑ Windows 32-bit
∑ Windows 64-bit
∑ Solaris i86pc
∑ Solaris 64
∑ You can download the source and install MongoDb from that too.
MongoDB : Databases, Schemas and Tables
Databases : MongoDB is a document-oriented DBMS, with JSON-like objects
comprising the data model, rather than RDBMS tables. MongoDB does not
support joins nor transactions. However, it features secondary indexes, an
expressive query language, atomic writes on a per-document level, and fully-
consistent reads. MongoDB uses BSON, a binary object format similar to, but
more expressive than JSON.
Schemas : MongoDB uses dynamic schemas. We can create collections without
defining the structure, i.e. the fields or the types of their values, of the
documents. You can change the structure of documents simply by adding new
fields or deleting existing ones. Documents in a collection need unique set of
fields.
Tables : MongoDB database stores its data in collections not in tables The
collections are the rough equivalent of RDBMS tables. A collection holds one or
more documents, which corresponds to a record or a row in a relational database
table, and each document has one or more fields, which corresponds to a
column in a relational database table.
MongoDB and ACID transactions
MongoDB does not support multi-document transactions, but provides atomic
operations on a single document. Often these document-level atomic operations
are sufficient to solve problems that would require ACID transactions in a
relational database.
In MongoDB, you can embed related data in nested arrays or nested documents
within a single document and update the entire document in a single atomic
operation. Relational databases might represent the same kind of data with
multiple tables and rows, which would require transaction support to update the
data atomically.
MongoDB allows clients to read documents inserted or modified before it
commits these modifications to disk, regardless of write concern level or
journaling configuration. Applications may observe two classes of behaviors :
∑ MongoDB will allow clients to read the results of a write operation before the write operation
returns for systems with multiple concurrent readers and writers
∑ If the mongodb terminates before the journal commits, even if a write returns successfully,
queries may have read data that will not exist after the mongodb restarts.
Other database systems refer to these isolation semantics as read uncommitted.
For all inserts and updates, MongoDB modifies
∑ each document in isolation
∑ clients never see documents in intermediate states
For multi-document operations, MongoDB does not provide any multi-document
transactions or isolation. When mongodb returns a successful journaled write
concern, the data is fully committed to disk and will be available after mongodb
restarts. For replica sets, write operations are durable only after a write replicates
and commits to the journal of a majority of the voting members of the set.
MongoDB and caching
MongoDB has no configurable cache. MongoDB uses all free memory on the
system automatically by way of memory-mapped files. Operating systems use
the same approach with their file system caches. MongoDB keeps all of the most
recently used data in RAM. If you have created indexes for your queries and your
working data set fits in RAM, MongoDB serves all queries from memory.
MongoDB does not implement a query cache, it serves all queries directly from
the indexes and/or data files.
Tools
There are several tools available for managing MongoDB.
Monitoring
Network and System monitoring tool Munin has a plugin available for MongoDB.
Distributes high-performance system monitoring tool Gangila has a plugin
available for MongoDB.
Open source web based graphic tool Cacti, used to graph CPU load, network
bandwidth utilization, has a plugin available for MongoDB.
GUI
∑ Fang of Mongo is a web-based user interface built with Django and jQuery.
∑ Futon4Mongo is a clone of the CouchDB Futon web interface for MongoDB.
∑ Mongo3 is a Ruby-based interface.
∑ MongoHub is a native OS X application for managing MongoDB.
∑ Opricot is a browser-based MongoDB shell written in PHP.
∑ phpMoAdmin is a PHP based MongoDb management tool.
∑ MongoVUE is a Windows based GUI to work with MongoDB.
∑ RockMongo is a PHP based MongoDB administration GUI tool.
MongoDB in production
Here is a list of a few MongoDB production deployment:
∑ Craiglist uses MongoDb to archive there billions of records.
∑ FourSquare, a location based social networking site, uses MongoDb to shrade there data over a
number of machines on Amazon EC2.
∑ Shutterfly, an Internet-based social expression and personal publishing service, uses MongoDb
for various persistent data storage requirements.
∑ bit.ly, a web based url shortening service, uses MongoDb for storing their data.
∑ spike.com, a MTV Network's associate, uses MongoDB.
∑ Intuit, a large provider of software and services for small businesses and individuals, uses
MongoDB to track user engagement and activity in real-time across its network of websites for
small businesses.
∑ sourceforge.net, a site to find, create and publish Open Source Software for free, uses
MongoDB for back-end storage.
∑ etsy.com, a site to buy and sell handmade items, uses MongoDB.
∑ The New York Times, one of the leading online news portal, is using MongoDB in a form-
building application for photo submissions.
∑ CERN, the prestigious particle Physics research institute, uses MongoDB for Large Hadron
Collider data.
What is ExpressJs?
Express is a framework of Node.js that allows you to use several very useful and powerful
features without having to reinvent the wheel, helps you organize your application's routing
and use any templating solution with minimal effort. It also allows for much better
organization of your code. In my personal opinion, Express.js is the best Node.js framework
but Meteor.js, Derby.js, Sails.js and Flatiron.js are some of the best alternatives. Especially
Meteor which is more of a full stack framework is superb and can do quite impressive things
with minimal effort.
What is AngularJs?
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your
template language and lets you extend HTML's syntax to express your application's
components clearly and succinctly. Angular's data binding and dependency injection eliminate
much of the code you would otherwise have to write.
<!DOCTYPE html>
<html>
<script
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="">
<p>Input something in the input box:</p>
<p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p>
<h1>Hello {{name}}</h1>
</div>
</body>
</html>
For info visit PHP Support Desk

More Related Content

DOCX
Node js getting started
Pallavi Srivastava
 
PDF
Node js first look - 2016
Yauheni Nikanovich
 
PPTX
Node js crash course session 2
Abdul Rahman Masri Attal
 
PPTX
A slightly advanced introduction to node.js
Sudar Muthu
 
PPTX
Nodejs server lesson 3
SamuelAdetunji2
 
PDF
Node JS Crash Course
Haim Michael
 
PPTX
Introduction to Node.js
Winston Hsieh
 
Node js getting started
Pallavi Srivastava
 
Node js first look - 2016
Yauheni Nikanovich
 
Node js crash course session 2
Abdul Rahman Masri Attal
 
A slightly advanced introduction to node.js
Sudar Muthu
 
Nodejs server lesson 3
SamuelAdetunji2
 
Node JS Crash Course
Haim Michael
 
Introduction to Node.js
Winston Hsieh
 

What's hot (20)

PPT
Node js
umesh patil
 
PPTX
Node js crash course session 5
Abdul Rahman Masri Attal
 
PPTX
Node js for beginners
Arjun Sreekumar
 
PDF
Introduction to REST API with Node.js
Yoann Gotthilf
 
PPTX
Node js crash course session 3
Abdul Rahman Masri Attal
 
PDF
NodeJS ecosystem
Yukti Kaura
 
PDF
Web Development with AngularJS, NodeJS and ExpressJS
João Rocha da Silva
 
PPTX
Ajax xml json
Andrii Siusko
 
PPTX
MongoDB basics & Introduction
Jerwin Roy
 
PDF
Ng init | EPI Sousse
Hamdi Hmidi
 
PPTX
Top 10 frameworks of node js
HabileLabs
 
PPTX
Using Webservice in iOS
Mahboob Nur
 
PPTX
Mongodb tutorial by Rajendra Arora
Rajendra Arora
 
PPTX
Mongo db
Raghu nath
 
PDF
Optimizing MongoDB: Lessons Learned at Localytics
andrew311
 
PPTX
Webinar Back to Basics 3 - Introduzione ai Replica Set
MongoDB
 
PPTX
MongoDB on Windows Azure
MongoDB
 
PDF
Flask jwt authentication tutorial
Katy Slemon
 
PDF
Mongodb
Scott Motte
 
PPTX
Introduction to mongo db
NexThoughts Technologies
 
Node js
umesh patil
 
Node js crash course session 5
Abdul Rahman Masri Attal
 
Node js for beginners
Arjun Sreekumar
 
Introduction to REST API with Node.js
Yoann Gotthilf
 
Node js crash course session 3
Abdul Rahman Masri Attal
 
NodeJS ecosystem
Yukti Kaura
 
Web Development with AngularJS, NodeJS and ExpressJS
João Rocha da Silva
 
Ajax xml json
Andrii Siusko
 
MongoDB basics & Introduction
Jerwin Roy
 
Ng init | EPI Sousse
Hamdi Hmidi
 
Top 10 frameworks of node js
HabileLabs
 
Using Webservice in iOS
Mahboob Nur
 
Mongodb tutorial by Rajendra Arora
Rajendra Arora
 
Mongo db
Raghu nath
 
Optimizing MongoDB: Lessons Learned at Localytics
andrew311
 
Webinar Back to Basics 3 - Introduzione ai Replica Set
MongoDB
 
MongoDB on Windows Azure
MongoDB
 
Flask jwt authentication tutorial
Katy Slemon
 
Mongodb
Scott Motte
 
Introduction to mongo db
NexThoughts Technologies
 
Ad

Viewers also liked (20)

PPTX
EAIESB TIBCO EXPERTISE
Vijay Reddy
 
PDF
Introduction to Node.JS Express
Eueung Mulyana
 
PDF
NodeJS_Presentation
Arpita Patel
 
PPTX
Mule ESB session day 1
kkk_f17
 
PDF
Enterprise Integration Patterns
Oleg Tsal-Tsalko
 
PPT
Managing Patient SatLEADfor4-25-13
alfred lopez
 
PDF
Node JS Express: Steps to Create Restful Web App
Edureka!
 
PPTX
Module design pattern i.e. express js
Ahmed Assaf
 
PDF
Patterns for Enterprise Integration Success
WSO2
 
PDF
Enterprise Integration Patterns
Johan Aludden
 
PPTX
Enterprise Integration Patterns
Sergey Podolsky
 
PPTX
Node JS Express : Steps to Create Restful Web App
Edureka!
 
PDF
Enterprise Integration Patterns Revisited (again) for the Era of Big Data, In...
Kai Wähner
 
PDF
Node js
Rohan Chandane
 
PPT
Implementation in mule esb
Vamsi Krishna
 
PPTX
API and SOA: Two Sides of the Same Coin?
Akana
 
PDF
Differentiating between web APIs, SOA, & integration …and why it matters
Kim Clark
 
PDF
Integration Patterns and Anti-Patterns for Microservices Architectures
Apcera
 
PDF
REST vs. Messaging For Microservices
Eberhard Wolff
 
PPTX
Express JS
Designveloper
 
EAIESB TIBCO EXPERTISE
Vijay Reddy
 
Introduction to Node.JS Express
Eueung Mulyana
 
NodeJS_Presentation
Arpita Patel
 
Mule ESB session day 1
kkk_f17
 
Enterprise Integration Patterns
Oleg Tsal-Tsalko
 
Managing Patient SatLEADfor4-25-13
alfred lopez
 
Node JS Express: Steps to Create Restful Web App
Edureka!
 
Module design pattern i.e. express js
Ahmed Assaf
 
Patterns for Enterprise Integration Success
WSO2
 
Enterprise Integration Patterns
Johan Aludden
 
Enterprise Integration Patterns
Sergey Podolsky
 
Node JS Express : Steps to Create Restful Web App
Edureka!
 
Enterprise Integration Patterns Revisited (again) for the Era of Big Data, In...
Kai Wähner
 
Implementation in mule esb
Vamsi Krishna
 
API and SOA: Two Sides of the Same Coin?
Akana
 
Differentiating between web APIs, SOA, & integration …and why it matters
Kim Clark
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Apcera
 
REST vs. Messaging For Microservices
Eberhard Wolff
 
Express JS
Designveloper
 
Ad

Similar to Node Js, AngularJs and Express Js Tutorial (20)

PPTX
MongoDB NoSQL - Developer Guide
Shiv K Sah
 
PPTX
MongoDB presentation
Hyphen Call
 
PPTX
how_can_businesses_address_storage_issues_using_mongodb.pptx
sarah david
 
PDF
What is mean stack?
Rishabh Saxena
 
PDF
Mongo db dhruba
Dhrubaji Mandal ♛
 
PDF
Pros and Cons of MongoDB in Web Development
Nirvana Canada
 
PDF
how_can_businesses_address_storage_issues_using_mongodb.pdf
sarah david
 
PPTX
Everything You Need to Know About MongoDB Development.pptx
75waytechnologies
 
PPTX
nodejs.pptx
shamsullah shamsi
 
PDF
Mongo db transcript
foliba
 
PPT
Introduction to mean and mern || Event by DSC UNIDEB
Muhammad Raza
 
PPTX
Analytical data processing
Polad Saruxanov
 
PPTX
05201349_Unit_7_FSWD_ advanced learning.pptx
ozakamal8
 
PPTX
05201349_Unit_7_FSWD_II(1) with advance.pptx
ozakamal8
 
PPTX
05201349_Unit_7_FSWD_ advanced learning.pptx
ozakamal8
 
PPTX
05201349_Unit_7_FSWD_II(1) with advance.pptx
ozakamal8
 
PDF
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Laura Ventura
 
PPTX
Mongo db
Gyanendra Yadav
 
TXT
edit and approve 2
Bhavani Testone
 
TXT
upload.txt
IshNexus
 
MongoDB NoSQL - Developer Guide
Shiv K Sah
 
MongoDB presentation
Hyphen Call
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
sarah david
 
What is mean stack?
Rishabh Saxena
 
Mongo db dhruba
Dhrubaji Mandal ♛
 
Pros and Cons of MongoDB in Web Development
Nirvana Canada
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
sarah david
 
Everything You Need to Know About MongoDB Development.pptx
75waytechnologies
 
nodejs.pptx
shamsullah shamsi
 
Mongo db transcript
foliba
 
Introduction to mean and mern || Event by DSC UNIDEB
Muhammad Raza
 
Analytical data processing
Polad Saruxanov
 
05201349_Unit_7_FSWD_ advanced learning.pptx
ozakamal8
 
05201349_Unit_7_FSWD_II(1) with advance.pptx
ozakamal8
 
05201349_Unit_7_FSWD_ advanced learning.pptx
ozakamal8
 
05201349_Unit_7_FSWD_II(1) with advance.pptx
ozakamal8
 
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Laura Ventura
 
Mongo db
Gyanendra Yadav
 
edit and approve 2
Bhavani Testone
 
upload.txt
IshNexus
 

Recently uploaded (20)

PPTX
B2B_Ecommerce_Internship_Simranpreet.pptx
LipakshiJindal
 
PDF
Project English Paja Jara Alejandro.jpdf
AlejandroAlonsoPajaJ
 
PPTX
办理方法西班牙假毕业证蒙德拉贡大学成绩单MULetter文凭样本
xxxihn4u
 
PDF
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
PPTX
ENCOR_Chapter_11 - ‌BGP implementation.pptx
nshg93
 
PDF
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
PPTX
how many elements are less than or equal to a mid value and adjusts the searc...
kokiyon104
 
PDF
“Google Algorithm Updates in 2025 Guide”
soohhhnah
 
PPTX
Google SGE SEO: 5 Critical Changes That Could Wreck Your Rankings in 2025
Reversed Out Creative
 
PDF
Generative AI Foundations: AI Skills for the Future of Work
hemal sharma
 
PDF
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
PPTX
谢尔丹学院毕业证购买|Sheridan文凭不见了怎么办谢尔丹学院成绩单
mookxk3
 
PDF
5g is Reshaping the Competitive Landscape
Stellarix
 
PPTX
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
PPTX
Crypto Recovery California Services.pptx
lionsgate network
 
PPT
Transformaciones de las funciones elementales.ppt
rirosel211
 
PPTX
dns domain name system history work.pptx
MUHAMMADKAVISHSHABAN
 
PDF
Centralized Business Email Management_ How Admin Controls Boost Efficiency & ...
XgenPlus Technologies
 
PPTX
Black Yellow Modern Minimalist Elegant Presentation.pptx
nothisispatrickduhh
 
PPTX
EthicalHack{aksdladlsfsamnookfmnakoasjd}.pptx
dagarabull
 
B2B_Ecommerce_Internship_Simranpreet.pptx
LipakshiJindal
 
Project English Paja Jara Alejandro.jpdf
AlejandroAlonsoPajaJ
 
办理方法西班牙假毕业证蒙德拉贡大学成绩单MULetter文凭样本
xxxihn4u
 
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
ENCOR_Chapter_11 - ‌BGP implementation.pptx
nshg93
 
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
how many elements are less than or equal to a mid value and adjusts the searc...
kokiyon104
 
“Google Algorithm Updates in 2025 Guide”
soohhhnah
 
Google SGE SEO: 5 Critical Changes That Could Wreck Your Rankings in 2025
Reversed Out Creative
 
Generative AI Foundations: AI Skills for the Future of Work
hemal sharma
 
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
谢尔丹学院毕业证购买|Sheridan文凭不见了怎么办谢尔丹学院成绩单
mookxk3
 
5g is Reshaping the Competitive Landscape
Stellarix
 
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
Crypto Recovery California Services.pptx
lionsgate network
 
Transformaciones de las funciones elementales.ppt
rirosel211
 
dns domain name system history work.pptx
MUHAMMADKAVISHSHABAN
 
Centralized Business Email Management_ How Admin Controls Boost Efficiency & ...
XgenPlus Technologies
 
Black Yellow Modern Minimalist Elegant Presentation.pptx
nothisispatrickduhh
 
EthicalHack{aksdladlsfsamnookfmnakoasjd}.pptx
dagarabull
 

Node Js, AngularJs and Express Js Tutorial

  • 1. Stack RESTful API Tutorial - Using MongoDB, Express, Angular JS, and Node JS Together Before starting on these let us discuss about the platforms terms. 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 and its latest version is v0.10.36. The definition of Node.js as supplied by its official documentation is as follows − Node.js is a platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. 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. Node.js = Runtime Environment + JavaScript Library Features of Node.js Following are some of the important features that make Node.js the first choice of software architects. ∑ Asynchronous and Event Driven All APIs of Node.js library are asynchronous that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.
  • 2. ∑ Very Fast Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution. ∑ Single Threaded but Highly Scalable - Node.js uses a single threaded model with event looping. Event mechanism helps the server to respond in a non- blocking way and makes the server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and the same program can provide service to a much larger number of requests than traditional servers like Apache HTTP Server. ∑ No Buffering - Node.js applications never buffer any data. These applications simply output the data in chunks. ∑ License - Node.js is released under the MIT license. Who Uses Node.js? Following is the link on github wiki containing an exhaustive list of projects, application and companies which are using Node.js. This list includes eBay, General Electric, GoDaddy, Microsoft, PayPal, Uber, Wikipins, Yahoo!, and Yammer to name a few. ∑ Projects, Applications, and Companies Using Node Concepts The following diagram depicts some important parts of Node.js which we will discuss in detail in the subsequent chapters.
  • 3. Where to Use Node.js? Following are the areas where Node.js is proving itself as a perfect technology partner. ∑ I/O bound Applications ∑ Data Streaming Applications ∑ Data Intensive Real time Applications (DIRT) ∑ JSON APIs based Applications ∑ Single Page Applications Where Not to Use Node.js? It is not advisable to use Node.js for CPU intensive applications. What is MongoDb? MongoDb is a Open Source database written in C++. Drivers and client libraries are typically written in their respective languages, although some drivers use C extensions for better performance. If the load increases, by adding more nodes (such as a computer), the performance can be retained.
  • 4. It can be used to store data for very high performance applications (for example Foursquare is using it in production). MongoDB does not support SQL It supports a rich, ad-hoc query language of its own. MongoDb stores data as documents. So it is a document oriented database. FirstName="Arun", Address="St. Xavier's Road", Spouse=[{Name:"Kiran"}], Children=[{Name:"Rihit", Age:8}]. FirstName="Sameer",Address="8 Gandhi Road". Notice there are two different documents (separated by "."). Storing data in this fashion is called asdocument oriented database. MongoDb is a document oriented database. Key Features Since MongoDb offers a Document oriented storage, It is simple and easily programmable. ∑ You can set an index on any attribute of a MongoDb record (as FirstName="Sameer",Address="8 Gandhi Road"), with respect to which, a record can be sort quickly and ordered. ∑ You can set mirror across local as well as wide area networks, which makes it easily scalable. ∑ If load increases (more storage space, more processing power), it can be distributed to other nodes across computer networks. This is called as sharding. ∑ MongoDb supports rich query to fetch data from the database. ∑ MongoDb supports replacing an entire document (database) or some specific fields with it's update() command. ∑ MongoDb supports Map/Reduce framework for batch processing of data and aggregation operation. Here is brief of how Map/Reduce works : ∑ Map : A master node takes an input. Splits it into smaller sections. Sends it to the associated nodes. ∑ These nodes may perform the same operation in turn to send those smaller section of input to other nodes. It process the problem (taken as input) and sends it back to the Master Node.
  • 5. ∑ Reduce : The master node aggregates those results to find the output. ∑ GridFS specification of MongoDb supports storage of very large files. ∑ MongoDb supports various programming languages like C, C# and .NET, C++, Erlang, Haskell, Java, Javascript, Perl, PHP, Python, Ruby, Scala (via Casbah). ∑ It supports Server-side JavaScript execution. Which allows a developer to use a single programming language for both client and server side code. ∑ MongoDb is easily installable. MongoDB Fundamentals : Frequently Asked Questions What kind of database is MongoDB? MongoDB is a document-oriented DBMS. Think of MySQL but with JSON-like objects comprising the data mode, rather than RDBMS tables. MongoDB supports neither joins nor transactions. Do MongoDB database stores its data in tables? A MongoDB database stores its data in collections instead of tables, which are the rough equivalent of RDBMS tables. Do MongoDB databases have schemas? MongoDB uses dynamic schemas. Without defining the structure you can create collections, i.e. the fields or the types of their values, of the documents in the collection. You can change the structure of documents simply by adding new fields or deleting existing ones. Which programming languages can be used to work with MongoDB? MongoDB client drivers exist for all of the most popular programming languages. See the latest list of drivers for details. Does MongoDB support SQL? No. What are typical uses for MongoDB? Content management systems, mobile applications, gaming, e-commerce, analytics, archiving, and logging. Does MongoDB support transactions? No. However, MongoDB does provide atomic operations on a single document. Does MongoDB require a lot of RAM? Not necessarily. It's certainly possible to run MongoDB on a machine with a small amount of free RAM. MongoDB automatically uses all free memory on the machine as its cache. Does MongoDB handle caching? Yes. MongoDB keeps all of the most recently used data in RAM. If you have created indexes for your queries and your working data set fits in RAM, MongoDB serves all queries from memory.
  • 6. What are the limitations of 32-bit versions of MongoDB? Changed in version 3.0: Commercial support is no longer provided for MongoDB on 32-bit platforms (Linux and Windows). History Development of MongoDB began in October 2007 by 10gen. The first public release was in February 2009. Obtain MongoDb You can download MongoDb from http://www.mongodb.org/downloads. As of this writing, it supports following platforms: ∑ OS X 32-bit ∑ OS X 64-bit ∑ Linux 32-bit ∑ Linux 64-bit ∑ Windows 32-bit ∑ Windows 64-bit ∑ Solaris i86pc ∑ Solaris 64 ∑ You can download the source and install MongoDb from that too. MongoDB : Databases, Schemas and Tables Databases : MongoDB is a document-oriented DBMS, with JSON-like objects comprising the data model, rather than RDBMS tables. MongoDB does not support joins nor transactions. However, it features secondary indexes, an expressive query language, atomic writes on a per-document level, and fully- consistent reads. MongoDB uses BSON, a binary object format similar to, but more expressive than JSON. Schemas : MongoDB uses dynamic schemas. We can create collections without defining the structure, i.e. the fields or the types of their values, of the documents. You can change the structure of documents simply by adding new fields or deleting existing ones. Documents in a collection need unique set of fields. Tables : MongoDB database stores its data in collections not in tables The collections are the rough equivalent of RDBMS tables. A collection holds one or more documents, which corresponds to a record or a row in a relational database
  • 7. table, and each document has one or more fields, which corresponds to a column in a relational database table. MongoDB and ACID transactions MongoDB does not support multi-document transactions, but provides atomic operations on a single document. Often these document-level atomic operations are sufficient to solve problems that would require ACID transactions in a relational database. In MongoDB, you can embed related data in nested arrays or nested documents within a single document and update the entire document in a single atomic operation. Relational databases might represent the same kind of data with multiple tables and rows, which would require transaction support to update the data atomically. MongoDB allows clients to read documents inserted or modified before it commits these modifications to disk, regardless of write concern level or journaling configuration. Applications may observe two classes of behaviors : ∑ MongoDB will allow clients to read the results of a write operation before the write operation returns for systems with multiple concurrent readers and writers ∑ If the mongodb terminates before the journal commits, even if a write returns successfully, queries may have read data that will not exist after the mongodb restarts. Other database systems refer to these isolation semantics as read uncommitted. For all inserts and updates, MongoDB modifies ∑ each document in isolation ∑ clients never see documents in intermediate states For multi-document operations, MongoDB does not provide any multi-document transactions or isolation. When mongodb returns a successful journaled write concern, the data is fully committed to disk and will be available after mongodb restarts. For replica sets, write operations are durable only after a write replicates and commits to the journal of a majority of the voting members of the set. MongoDB and caching MongoDB has no configurable cache. MongoDB uses all free memory on the system automatically by way of memory-mapped files. Operating systems use the same approach with their file system caches. MongoDB keeps all of the most recently used data in RAM. If you have created indexes for your queries and your working data set fits in RAM, MongoDB serves all queries from memory.
  • 8. MongoDB does not implement a query cache, it serves all queries directly from the indexes and/or data files. Tools There are several tools available for managing MongoDB. Monitoring Network and System monitoring tool Munin has a plugin available for MongoDB. Distributes high-performance system monitoring tool Gangila has a plugin available for MongoDB. Open source web based graphic tool Cacti, used to graph CPU load, network bandwidth utilization, has a plugin available for MongoDB. GUI ∑ Fang of Mongo is a web-based user interface built with Django and jQuery. ∑ Futon4Mongo is a clone of the CouchDB Futon web interface for MongoDB. ∑ Mongo3 is a Ruby-based interface. ∑ MongoHub is a native OS X application for managing MongoDB. ∑ Opricot is a browser-based MongoDB shell written in PHP. ∑ phpMoAdmin is a PHP based MongoDb management tool. ∑ MongoVUE is a Windows based GUI to work with MongoDB. ∑ RockMongo is a PHP based MongoDB administration GUI tool. MongoDB in production Here is a list of a few MongoDB production deployment: ∑ Craiglist uses MongoDb to archive there billions of records. ∑ FourSquare, a location based social networking site, uses MongoDb to shrade there data over a number of machines on Amazon EC2. ∑ Shutterfly, an Internet-based social expression and personal publishing service, uses MongoDb for various persistent data storage requirements. ∑ bit.ly, a web based url shortening service, uses MongoDb for storing their data. ∑ spike.com, a MTV Network's associate, uses MongoDB.
  • 9. ∑ Intuit, a large provider of software and services for small businesses and individuals, uses MongoDB to track user engagement and activity in real-time across its network of websites for small businesses. ∑ sourceforge.net, a site to find, create and publish Open Source Software for free, uses MongoDB for back-end storage. ∑ etsy.com, a site to buy and sell handmade items, uses MongoDB. ∑ The New York Times, one of the leading online news portal, is using MongoDB in a form- building application for photo submissions. ∑ CERN, the prestigious particle Physics research institute, uses MongoDB for Large Hadron Collider data. What is ExpressJs? Express is a framework of Node.js that allows you to use several very useful and powerful features without having to reinvent the wheel, helps you organize your application's routing and use any templating solution with minimal effort. It also allows for much better organization of your code. In my personal opinion, Express.js is the best Node.js framework but Meteor.js, Derby.js, Sails.js and Flatiron.js are some of the best alternatives. Especially Meteor which is more of a full stack framework is superb and can do quite impressive things with minimal effort. What is AngularJs? AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you would otherwise have to write. <!DOCTYPE html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app=""> <p>Input something in the input box:</p> <p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p> <h1>Hello {{name}}</h1> </div>
  • 10. </body> </html> For info visit PHP Support Desk