Introduction

What Node.js is

Node.js is an open source, cross-platform runtime environment for 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, Linux, FreeBSD, NonStop and IBM i.

Advantages

Web development is done in a dynamic language (JavaScript) on a VM that is incredibly fast (V8). It is much faster than Ruby, Python, or Perl. Ability to handle thousands of concurrent connections with minimal overhead on a single process. JavaScript is perfect for event loops with first class function objects and closures. People already know how to use it this way having used it in the browser to respond to user-initiated events. Many people already know JavaScript, even people who do not claim to be programmers. It is arguably the most popular programming language. Using JavaScript on a web server as well as the browser reduces the impedance mismatch between the two programming environments that can communicate data structures via JSON that work the same on both sides of the equation. Duplicate form validation code can be shared between server and client and so on.

Installation

Install npm (https://nodejs.org/) Install Visual Studio 2012 Install SQL Server 2008 r2 NTVS 1.0 RC 2 Visual Studio 2012(https://nodejstools.codeplex.com/releases/view/612573) Use Angular js library

Procedure

Create a table in your database and insert a row as in the following:

CREATE TABLE [dbo].[Nodejs]( [Id] [ int ] IDENTITY(1,1) NOT NULL , [Text] [nvarchar](50) NULL , CONSTRAINT [PK_Nodejs] PRIMARY KEY CLUSTERED ( [Id] ASC ) WITH (PAD_INDEX = OFF , STATISTICS_NORECOMPUTE = OFF , IGNORE_DUP_KEY = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON ) ON [ PRIMARY ] ) ON [ PRIMARY ]

INSERT INTO [IMS1.0].[dbo].[Nodejs] ([Text]) VALUES ( 'Hello word!!' ) GO

Open the project in Visual Studio and you will see the following folder structure:

Insert a row into the table as in the following:

How to install all packages

Right-click on npm and select Install New npm Packages.

Open the api.js file and set the Microsoft SQL database credentials and database name.

Enter the following query:





Please download the code and use the following procedure and run the code.

Output Window