View Source DSL: AshUlid.Resource

Ash resource extension which adds ulid_primary_key to attributes section.

attributes.ulid_primary_key

ulid_primary_key name

Declares a non writable, non-nil, primary key column of type ulid, which defaults to AshUlid.generate/0.

Accepts all the same options as Ash.Resource.Dsl.attributes.attribute, except for allow_nil?, but it sets the following different defaults:

writable? false
public? true
default &AshUlid.generate/0
primary_key? true
type AshUlid.Type

Examples

ulid_primary_key :id

Arguments

NameTypeDefaultDocs
nameatomThe name of the attribute.

Options

NameTypeDefaultDocs
typemoduleAshUlid.TypeThe type of the attribute. See Ash.Type for more.
constraintskeywordConstraints to provide to the type when casting the value. For more, see Ash.Type.
descriptionString.tAn optional description for the attribute.
sensitive?booleanfalseWhether or not the attribute value contains sensitive information, like PII. See the Sensitive Data guide for more.
sourceatomIf the field should be mapped to a different name in the data layer. Support varies by data layer.
always_select?booleanfalseWhether or not to ensure this attribute is always selected when reading from the database, regardless of applied select statements.
primary_key?booleantrueWhether the attribute is the primary key. Composite primary key is also possible by using primary_key? true in more than one attribute. If primary_key? is true, allow_nil? must be false.
generated?booleanfalseWhether or not the value may be generated by the data layer.
writable?booleanfalseWhether or not the value can be written to. Non-writable attributes can still be written with Ash.Changeset.force_change_attribute/3.
public?booleantrueWhether or not the attribute should be shown over public interfaces. See the sensitive data guide for more.
default(-> any) | mfa | any&AshUlid.generate/0A value to be set on all creates, unless a value is being provided already. Note: The default value is casted according to the type's Ash.Type. module, before it is saved. For :string, for example, if constraints: [allow_empty?: _] is false, the value "" will be cast to nil. See the :constraints option, the :allow_nil? option, and the relevant `Ash.Type.` documentation.
update_default(-> any) | mfa | anyA value to be set on all updates, unless a value is being provided already.
filterable?boolean | :simple_equalitytrueWhether or not the attribute can be referenced in filters.
sortable?booleantrueWhether or not the attribute can be referenced in sorts.
match_other_defaults?booleanfalseEnsures that other attributes that use the same "lazy" default (a function or an mfa), use the same default value. Has no effect unless default is a zero argument function.

Introspection

Target: Ash.Resource.Attribute