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
Name | Type | Default | Docs |
---|---|---|---|
name | atom | The name of the attribute. |
Options
Name | Type | Default | Docs |
---|---|---|---|
type | module | AshUlid.Type | The type of the attribute. See Ash.Type for more. |
constraints | keyword | Constraints to provide to the type when casting the value. For more, see Ash.Type . | |
description | String.t | An optional description for the attribute. | |
sensitive? | boolean | false | Whether or not the attribute value contains sensitive information, like PII. See the Sensitive Data guide for more. |
source | atom | If the field should be mapped to a different name in the data layer. Support varies by data layer. | |
always_select? | boolean | false | Whether or not to ensure this attribute is always selected when reading from the database, regardless of applied select statements. |
primary_key? | boolean | true | Whether 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? | boolean | false | Whether or not the value may be generated by the data layer. |
writable? | boolean | false | Whether or not the value can be written to. Non-writable attributes can still be written with Ash.Changeset.force_change_attribute/3 . |
public? | boolean | true | Whether or not the attribute should be shown over public interfaces. See the sensitive data guide for more. |
default | (-> any) | mfa | any | &AshUlid.generate/0 | A 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 | any | A value to be set on all updates, unless a value is being provided already. | |
filterable? | boolean | :simple_equality | true | Whether or not the attribute can be referenced in filters. |
sortable? | boolean | true | Whether or not the attribute can be referenced in sorts. |
match_other_defaults? | boolean | false | Ensures 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