Skip to content

[Feature] Automatic audit function #1956

@ilxqx

Description

@ilxqx

Motivation

Many times, our table structure will have fields like: created_at, updated_at, created_by, updated_by. These fields are usually generated automatically by the ORM framework.

For example:created_at is only generated during insert, updated_at is generated during insert or update.

Proposed Solutions

Although these functions can be implemented through the Entity's Hook (ActiveModelBehavior), it is redundant to write them for each entity, and it doesn't make sense. I hope the framework can have the functionality of global hooks, and at the same time, the framework can also provide several commonly used global hooks (such as AuditableHook). Users can also customize global hooks (for example, implementing automatic auditing for created_by and updated_by).

I think this will be a powerful feature, providing more hooks will be more convenient.

Another suggestion is that there is a lack of after_get/after_query hooks in ActiveModelBehavior. This hook can implement further processing of the queried Model(For example: unified data dictionary translation for some fileds in Model.).

Current Workarounds

Hardcoding, repetitive copying

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions