wimwian

wimwian

Hi,

I have a requirement to track the user who created the record and the user who last updated the record for audit purposes.

I have added two fields to the schema (created_by and last_modified_by).

I was checking the timestamps() code in ecto git repository to understand how I could update the values in these attributes where I noticed two module attributes (ecto_autogenerate and ecto_autoupdate).

My understanding is that ecto_autogenerate is triggered when autogenerate is set to true or a {module, function, attributes} tuple is set for the field in schema definition.

Also, another thought was autogenerate will be triggered at insert while autoupdate shall be trigged at update, However, I could not find any documenration on ecto_autoupdate except for these three lines of code in schema.ex

find . -name “*.ex” -print | xargs grep -in ecto_autoupdate
./lib/ecto/schema.ex:438: Module.register_attribute(MODULE, :ecto_autoupdate, accumulate: true)
./lib/ecto/schema.ex:522: autoupdate = @ecto_autoupdate |> Enum.reverse
./lib/ecto/schema.ex:654: Module.put_attribute(MODULE, :ecto_autoupdate, {[updated_at], autogen})

Can someone explain how the ecto_autoupdate attribute is expected to work?

Thank you!

Where Next? Top

Trending in Chat/Questions Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews