Node.js Product Catalog application that uses SQL/JSON functionalities
This project contains an example implementation of Node.js application that shows how to display list of products, add, edit, or delete products in the list.
Contents
About this sample
Before you begin
Run this sample
Sample details
Disclaimers
Related links
About this sample
- Applies to: SQL Server 2016 (or higher), Azure SQL Database
- Key features: JSON functions in SQL Server 2016/Azure SQL Database
- Programming Language: Html/JavaScript/Node.js, Transact-SQL
- Authors: Jovan Popovic
Before you begin
To run this sample, you need the following prerequisites.
Software prerequisites:
- SQL Server 2016 (or higher) or an Azure SQL Database
- Node.js installation
Azure prerequisites:
- Permission to create an Azure SQL Database
Run this sample
-
Create a database on SQL Server 2016 or Azure SQL Database and set compatibility level to 130.
-
From SQL Server Management Studio or Sql Server Data Tools connect to your SQL Server 2016 or Azure SQL database and execute sql-scripts/setup.sql script that will create and populate Product table and create required stored procedures.
-
From command line run npm update to update node.js packages.
-
Setup connection information db.js
-
Build and run sample using npm build and npm run.
-
Run the sample app using F5 or Ctrl+F5 in Visual Studio 2015, or using dotnet run executed in the command prompt of the project root folder.
-
Open http://localhost:3000/index.html to get all products from database,
-
Use Add button to add a new product,
-
Edit a product using Edit button in table,
-
Delete a product using Delete button in table,
Sample details
This sample application shows how to display list of products, add, edit or delete some product. Front-end code is implemented using JQuery/Bootstrap libraries, and JQuery DataTable component for displaying data in table. Server-side code is implemented using Node.js Express4 REST API. SQL Server JSON functions are used to format product data that will be sent to front-end page.
Disclaimers
The code included in this sample is not intended demonstrate some general guidance and architectural patterns for web development. It contains minimal code required to create REST API. You can easily modify this code to fit the architecture of your application.
Related Links
You can find more information about the components that are used in this sample on these locations:
Code of Conduct
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
License
These samples and templates are all licensed under the MIT license. See the license.txt file in the root.
Questions
Email questions to: [sqlserversamples@microsoft.com](mailto: sqlserversamples@microsoft.com).