Ash FrameworkAF
Ash Framework7mo ago
4 replies
Tommaso

:datetime with constraints vs :utc_datetime_usec

Hey all, I’m looking at the docs for the different datetime options and they mention

>A wrapper around :datetime for backwards compatibility

https://hexdocs.pm/ash/Ash.Type.UtcDatetimeUsec.html

In a new project with the latest version of Ash what is the most appropriate way to define a timestamp with microsecond precision?

Should I prefer:
attribute :xx, :datetime do
  constraints precision: microsecond
end

Or
attribute :xx, :utc_datetime_usec

I don’t quite understand what the implication of the “warning” about backward compatibility is :/
Solution
They are equivalent and will likely not change anytime soon. Someday we may warn when you use :utc_datetime_usec over the constraint.
Was this page helpful?