Answer the question
In order to leave comments, you need to log in
How to update the user in the database?
No attachment to language.
I have api, I send json with data for updating via endpoint (username, name, mail. password).
The problem is that not all data can be present in json, but only those that need to be updated.
I got the idea to check what data is present in the json file. And Separately, for each json field, call the update function of the corresponding column. But it's not efficient, is it? It is more efficient to send 1 request to update 4 columns.
How to implement a high-level update function?
Answer the question
In order to leave comments, you need to log in
If you have an ORM, then you load the entity, update the fields that came in the request, and save it to the database. Two requests (read and update).
If you work at the level of ordinary SQL queries, then you do something like:
UPDATE table SET field1=value1, field2=value2, ... WHERE id=idvalue;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question