V
V
Vladimir2017-03-12 19:06:18
MySQL
Vladimir, 2017-03-12 19:06:18

How to correctly connect client JS and server JS to the database?

Good evening, I wondered how to organize sending a request to the server and getting data from the database.
Tell me where and what to read and preferably in more detail.
I imagine the algorithm as follows, the client sends a request to the server JS, which in turn connects to the database and takes the data corresponding to my request from it, and then gives them to me on the client.
Please correct me if I'm wrong about anything.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nwton, 2017-03-12
@Nwton

1) Launching the application
2) Connecting to the database
3) Starting the server
4) The client sends a request
5) The application receives the request and Gets the data from the database to which it was previously connected, and then sends the data to the client
What to read? Google: mongo db, mongoose.

A
Andrew, 2017-03-14
@iCoderXXI

It looking on what the server. If it’s on Node.JS, then it connects when the script is launched, and when it receives a request, it simply goes to the database through an existing connection, and most likely asynchronously, so it’s even better if you don’t request data via Ajax server, but through websockets. Requested, after some time the server itself will send the data and process the event.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question