F
F
Fdrsmrdv2020-06-10 18:24:51
MongoDB
Fdrsmrdv, 2020-06-10 18:24:51

What is the best way to organize logging of data changes with saving to the database in Sails.js?

Hello!

Example:

We make a change to the Client model.
When saving the model, the beforeUpdate() and afterUdate() hooks are available to us .

We also have a Log model, in which we need to write down what and by whom has changed at the moment, the old and new values.

5ee0fbb025c21147245109.jpeg

My solution:

In beforeUpdate() we get the new values ​​and make a request to get the old data. Compare what has changed and create a change record.

But I feel it really badly :)

What is the best way to organize such logging?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question