Virtual Columns and Query Interception #453
Unanswered
DenisBessa
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
This is technically achievable to add such a new feature, but I'm having some doubts regarding if it is worthy. In general, I believe in separating business logic from the querying/persistance layer, and that's what Orchid ORM is - abstraction for querying and persisting. A little hint for this: "real" ORMs call their table abstraction classes as entities or models, while I'm calling them tables. Why you'd prefer uploading in the beforeHook or inside the query rather than before the query? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a specific question regarding the handling of virtual columns and query interception:
Consider a files table with an
idcolumn and a virtualdatacolumn that fetches file contents from an external service (e.g., S3).While the "JS runtime computed" feature enables async functions to retrieve data for the virtual data column, I'd like to implement the reverse operation: intercepting insert queries to execute an async function that uploads files to S3.
I attempted this using beforeHooks, but couldn't access the data of the row being inserted. The documentation indicates beforeHooks should return a function accepting a q parameter (presumably the executing query), but extracting data from it isn't clear.
The ability to define JavaScript functions for virtual columns excellently reduces complexity by keeping business rules at the table level, making select and insert operations behave like standard SQL columns. This functionality would be valuable.
Great work on the project.
Beta Was this translation helpful? Give feedback.
All reactions