List for logical deletion

Asked

Viewed 83 times

1

I have a question about who’s responsible (back or front) in my case, I have a list on front which is sent to the backend save or inactivate the record:

[{ idTabela: 2, codKit: "kitCopleto", dataInicio: "2019-01-01", dataFim: "2019-01-01"}, { idTabela: null, codKit: "kitCopleto2", dataInicio: "2019-01-01", dataFim: ""}]

Currently when the user deletes an item from that list, instead of setting the property DataFim with today’s date, we are physically deleting the item from the list and sending to backend.

Thus the backend is being responsible for performing a query in the database, bringing all items and comparing with the list you received from front, if the item has IdTabela so it already exists in the database and should be changed, otherwise it should be done the insert.

Every time I have to perform one select at the base bringing all the items, this would not be little performatic?

It would be better to work with 2 lists on front and send to the backend the list already with the dataFim items that were deleted by the user?

  • When you delete information that is rescued from a repository any your repository needs to know of this deletion ... after it knows you send to the front that the list does not exist such item ...

  • Ola Virgilio! Thanks for the answer, but this would only be possible if each deleted item was made a request...However, by definition UX was determined that it would only be deleted in fact after the user click on "finish"...that way, I am obliged to perform a single request by sending a list of items.

  • You only send the deleted items, and after return from the backend remove from the front !!!

  • Virgilio, the problem is a little bigger. The user can re-enter the same item that deleted or insert new items...so I can’t just forward the deleted ones, I should forward the new tbm records and always be checking if the inserted item has already been deleted, if the item was already registered or if it isif of only one Insert... Somewhere there must be this complexity...my doubt is whether the front would be responsible or the backend. OBS: I don’t need to wait for the backend to return...as the user clicks to immediately delete the item some from the list.

  • If your goal is when you record by the button then you know how to solve and you are already doing so, I would not do so I would each with its responsibility, but apparently you can not... So the rule is clear

  • @Paulobrunosoaressantos Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

Show 1 more comment

1 answer

1

Every time I have to perform one select at the base bringing all the items, this would not be little performatic?

Yes, it’s less performatic.

It would be better to work with 2 lists on front and send to the backend the list already with the dataFim items that were deleted by the user?

I don’t know, only you can answer, only you know all the details of the system. Can you tell anything about this.

You trusts information that comes from front? If so, then your software has serious security issues and probably doesn’t even know it. Data should only be validated on front if it makes no difference if in fact the data is invalid and is something that only helps the user to work better, if it is something important for the integrity of the system has no option, it can only be done in the backend.

If there is competition, any comparison should be made at the time you need and uniquely, otherwise you enter into running condition.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.