V
V
Vitaly2019-01-24 11:53:02
PostgreSQL
Vitaly, 2019-01-24 11:53:02

How to specify dependent selections and triggers in ORM?

Good time. The question is not easy, it will be easier to explain with an example.
I have a User table that has fields firstname , lastname and fullname (`${firstname} ${lastname}`).
You need to specify orm when changing firstname / lastname, do update fullname (this is a training example, it is assumed that there are not enough pl / sql tools and server logic is needed), and when requesting one of these three fields, always pull all three with one action (to use transactions and bypass mutual blocking).
A more complex example: the web version of the file manager. It is necessary to recursively update the total size of the folders in which they are located when changing the file size. In this case, you do not need to select information in one step for all system folders when reading the file (otherwise the database will work in single-threaded mode), but before changing the file size, you need to immediately pull up the necessary folders (for educational purposes, we will forget about the increment operation and will set new values in transaction mode).
It is advisable to suggest an implementation using TypeORM Node.js PostgreSQL as an example, but I will be happy to understand the solution using any ORM and PL that are convenient for you.

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