For example, the Massive Open Online Course net.
After making comments, this evaluation content is returned to the database, then the newly evaluated content is added to the database, and then the newly evaluated content is displayed after updating.
Can the front end do it? By what means?
Such as sending data
What about receiving data after the database?
Then display the updated comments after completing the database request?
First, the content is not returned to the database, but sent to or saved to the database.
To get down to business, the process you mentioned needs three parts, database, background logic (interface) and front end.
First of all, the interface is mainly responsible for the operation of the database. For example, you said that the operation of saving comments into the database, the interface to implement this operation, and let the front-end call. After the interface saves the data to the database, it will get the message returned by the database regardless of success or failure. Note that this place uses return. The data that the interface sends to the database is from the front end. The front end calls the interface through ajax request (this is more common). After sending the data to the interface, the interface will perform the above-mentioned save operation. Then the interface returns the message returned by the database to the front end again. If the message is successful, the front-end will display the comment in the comment list below. If the message is failed, it will indicate that the message has failed and the comment needs to be rewritten. The function of the database is the simplest (in actual production environment, the simpler the database is designed, the better). A comment table is provided. The interface adds, deletes, modifies and looks up the database table through sql statements, and then the database returns the operation results to the interface.
This is how the process looks. As for the above statement that js cannot operate the database, this statement is not accurate. Now node can write server code to operate the database. node uses js code. Accurately speaking, the front end does not directly operate the database.