8000 Auto add specific fields-values to create & update queries · Issue #537 · romeerez/orchid-orm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Auto add specific fields-values to create & update queries #537
Open
@romeerez

Description

@romeerez

Discussed in #517

Originally posted by krishna-404 May 31, 2025
I have fields createdByUserId & updatedByUserId. I want to auto add them to every create and update query as the case may be. What would be the best way to do this?

I was searching for some kind of query builder pattern for create and update but couldn't find anything, any direction would be great. Thanks!

  • drop updateSql (raw SQL values are still supported by a regular update) and change onConflict().set so that ORM can track what exact fields are being updated. (BREAKING_CHANGES.md at the root has more details on this)
  • in beforeCreate and beforeSave hook, add an utility to allow setting value when creating a record, it should work in all creational methods such as createMany, createFrom.
  • in beforeUpdate and beforeSave hook, add an utility to set a value when updating a record, it should work in all updating methods.
  • add readOnly method to columns to forbid inserting or updating the column on the type level.
  • add column-level helpers to set the values not from the before* hooks, but on the column definition itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0