I started new project for Retail Shop, I need to connect Angular 2/5 with MySQL Database using Node or any other method. I need Examples for Select, Create, Delete, Update. for now i need to create Login Page.
The only way you can do that is through http requests to the nodeJs server, since Angular runs in the web browser, while node runs on a server (javascript execution environment).
To create an Http service in Angular you can follow this link. In this way the nodejs server will be able to receive the data and be able to process them through a connection to mysql.
Well connecting Angular???
First learn that Angular, front end, does never connect to any database directly (not counting a New England db or LocalStorage as Database).
You need node or any other server side technology and then serve a REST API for providing data to your front end applications. SO actually your front end app in Angular is a complete separate application and your server side application will only connect to DB, handle logic and serve a REST API.
I use Sequelize for easy connecting and writing queries in JSON syntax.
Some more resources:
https://www.sitepoint.com/user-authentication-mean-stack/
https://medium.com/of-all-things-tech-progress/starting-with-authentication-a-tutorial-with-node-js-and-mongodb-25d524ca0359
Full Example app: http://jasonwatmore.com/post/2017/02/22/mean-with-angular-2-user-registration-and-login-example-tutorial
Angular is for your front end.
If you want Angular like syntax / Typescript for the back-end / server, have a look at: nest.
Nest (NestJS) is a framework for building scalable Node.js server-side applications.
Related
I've recently begun developing with NodeJS and ElectronJS to create some pretty nifty cross platform software. I want to take it a step further and integrate some database functionality.
While I'm aware that there are mysql packages available to install, I cringe at the idea that anybody can just unpack my asar.app file and see all of the connection details, including username, password, database name, table name, and other sensitive content that you really don't want to expose to people clever enough to break into your app's source code.
I've tried searching extensively on solutions to this problem, which I was surprised to find very little about. How do WhatsApp and Slack secure connections to their database if they were also built with ElectronJS?
Any and all resources are greatly appreciated. I basically want to be able to connect to a production server SQL database in an ElectronJS app without leaving some security backdoor to anybody who cracks the ASAR file.
Thank you!!
For this scenario, I suggest you to use a RESTful web service architecture. Basically you need 3 component, RESTful web back end, client application(your electron) and the database service( see the following image ; source:phppot.com) .For this I suggest you to use nodeJS backend and create a webservice using expressJS . You can define Restful (GET, POST,UPDATE, DELETE) API for each services.
For ex: To get some data from your db, you can send a GET request to the following path <yourdomain>:<port>/api/v1/getyoursomthin using your electron app. Your express app process the request and get the relevant data from the data from the database (Tutorial). So your app can get the respond from the server and display to the user. I will add link to some tutorials. You can find and learn more by google :)
Web: Build a simple app using Node JS and MySQL.
Express.js Tutorial: Build RESTful APIs with Node and Express
( source:phppot.com)
Good evening!
I would like to create a web application with Angular 6 but I would like to have Back-end mysql (This is the only basic form I understand a bit) only. Is it possible to have mysql as back-end and without having to use php?
I heard also about mongodb, but can we make requests with conditions for this management system (WHERE, LIKE ... as in sql).
There are two layers in your application - Angular is your front-end presentation layer and an API/Web Service is your back-end data layer which returns JSON data to the front-end. You can use any RDBMS provided your API service supports it. For example, .NET WebAPI supports MySQL through .NET Connector. You can use a variety of API platforms - PHP supports mysql through mysqli and other frameworks.
No, you can not communicate directly between Angular and MySQL. You'll need to build a back-end Web service that calls MySql using php or node. Angular can communicate with this back-end Web service via http.
Here are the steps you need:
1) Learn Angular. Start with the tutorial here: https://angular.io/tutorial
2) Learn how to build a back-end Web service to talk to your mysql backend. You could use php or node.js. See this article for more information. https://www.quora.com/How-do-I-connect-MySQL-to-an-Angular-4-application
3) Learn how to use Angular's http feature to talk to the back-end Web service. (Using the above linked tutorial for help.)
NOTE: You could use firebase instead. It does NOT require that you build a back-end Web service as it provides its own. You can find out more here: https://angularfirebase.com/ or here: https://github.com/angular/angularfire2
If you use Angular in front-end, you can use any backend with it to connect to MySQL database, for example:
Jersey web service written in Java
Php with mysqli
You can also use noSQL database with MongoDB or firebase.
The choice depends on the structure of your database (so you decide if it is better to have relational on noSQL database) and another very important thing is the hosting plan on which you want to deploy your website. If you have a shared server on which you have mySQL and you want to create a relational database, I recommend you to use the following architecture (Angular as front-end, php mysqli as back-end only to select/update from database, and mySQL to store database).
We're working on mobile app in ionic and we can't find how to insert mysql to ionic for example we have register interface we can input all informations but how can we save to the sqlserver thanks.
Ionic is a front end framework. To interface with Sql Server you will need some kind of backend to take care of interfacing with the database.
The .NET framework which is a C# backend, has terrific Sql Server integration given it is all a Microsoft product.
If you are looking for backend to be more or less taken care of I would recommend Firebase which is a back end as a service. It doesn't use Sql Server out of the box but can be used together.
I just started learning Node.js and want to handle a session using MySQL database. I want to do it without express or any kind of framework. I searched through google but couldn't manage to get an answer to my query. My present condition of this task is: I designed my .html files, created HTTP server using http module, managed to connect the database, and now desperately want to create a session (when a user logged in) and destroy it.
I am new in Node.js. Well i have experience in Backbone on Client side and Server side using PHP Laravel framework.
I want know is following connection/communication workflow is correct or possible:
My application is being designed using Backbone and its stacks and i can use Backbone model/collection to make service calls. But on Server side is it possible to create web service using Node.js (Without using any Server side scripting like PHP).
Am i using Node.js in correct direction at server end.
Here Node.js will perform CURD operations on database and return the result in JSON format.
Please suggest me what we can do here.
Yes, Node.js is fantastic at building scalable CRUD JSON APIs to your backend database.
You can use MySQL, MongoDB, Redis or any other number of databases on the backend. You'll find support in NPMjs.org for all the popular databases.
In addition to enhanced performance of Node.js over PHP, you can also make multiple database calls in parallel with Node.js. That's something PHP can't do. In PHP you must make your database calls sequentially. In Node.js you can make several calls in parallel so long as the calls are not interdependent.