Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser:
https://www.tutorialspoint.com/nodejs/nodejs_first_application.htm
Node.js lets developers use JavaScript to write Command Line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user’s web browser.
https://code.visualstudio.com/docs/nodejs/nodejs-tutorial
Node.js led to Callback Hell Which then was solved by the introduction of Node 7.6 Async/Await Support and “promises”
https://www.infoq.com/news/2017/02/node-76-async-await
=========================================
To get the data from node to a web browser, use a RESTful node.js server, coupled with a client-side data-grid that communicates with a REST server.
This example uses dojo’s dGrid on the client and Express for a REST API on the server: http://www.sw-at.com/
Better client-side data grids : jqGrid and SlickGrid, Here are a couple links on getting jqGrid working with a REST server:
http://stackoverflow.
http://www.
Good Grids:
Best inline editing with enter: https://paramquery.com/demos/editing
http://w2ui.com/web/demos/#!grid/grid-21
http://w2ui.com/kickstart/home
http://slickgrid.net/Index.html
https://www.primefaces.org/primereact/#/datatable/edit
List of grids: https://codegeekz.com/best-javascript-data-grid-libraries/
List of grids: https://www.angularminds.com/blog/article/15-useful-javascript-based-data-grid-libraries-for-web-app-development.html
=====================================================
npm is a package manager for the JavaScript programming language.
It is the default package manager for the JavaScript runtime environment Node.js.
Assuming you’ve already installed Node.js, create a directory to hold your application, and make that your working directory.
$ mkdir amirapp
$ cd amirapp
Use the npm init command to create a package.json file for your application. For more information on how package.json works, see Specifics of npm’s package.json handling.
$ npm init
This command prompts you for a number of things, such as the name and version of your application.
Hit RETURN to accept the defaults for most of them, with the following exception:
entry point: (index.js)
Enter mirappindex.js, or whatever you want the name of the main file to be. If you want it to be index.js, hit RETURN to accept the suggested default file name.
Now install Express in the myapp directory and save it in the dependencies list.
$ npm install express –save
var amirexpressv =require(‘express’);
var amirapp=express();
============================================================================================
Connection from Node.js to SQL
const mysql = require('mysql');
const pool = mysql.createPool({
host : 'example.org',
user : 'bob',
password : 'secret',
database : 'my_db'
});
const getConnection = () => {
return new Promise((resolve, reject) => {
pool.getConnection(function(err, connection) {
if (err) {
reject(err);
}
else {
resolve(connection);
}
});
});
}
module.exports = {
getConnection,
};
And you can get a connection from this pool like this:
getConnection().then((conn) => {
conn.query(<your query>, (error, results, fields) => {
// do things here;
conn.release();
});
})