ash v1.24.1 Ash.Resource.Dsl.IntegerPrimaryKey View Source

Link to this section Summary

Functions

Declares a generated (set by the data layer), non writable, non nil, primary key column of type integer

Link to this section Functions

Link to this macro

integer_primary_key(name, opts \\ [])

View Source (macro)

Declares a generated (set by the data layer), non writable, non nil, primary key column of type integer

Examples

integer_primary_key :id

Arguments

  • :name - The name of the attribute.

Options

  • :type - The type of the attribute. The default value is Ash.Type.Integer.

  • :constraints - Constraints to provide to the type when casting the value. See the type's documentation for more information.

  • :primary_key? - Whether or not the attribute is part of the primary key (one or more fields that uniquely identify a resource) The default value is true.

  • :allow_nil? - Whether or not the attribute can be set to nil The default value is false.

  • :generated? - Whether or not the value may be generated by the data layer. If it is, the data layer will know to read the value back after writing. The default value is true.

  • :writable? - Whether or not the value can be written to The default value is false.

  • :private? - Whether or not the attribute will appear in any interfaces created off of this resource, e.g AshJsonApi and AshGraphql The default value is false.

  • :update_default - A zero argument function, an {mod, fun, args} triple or a value. If no value is provided for the attribute on update, this value is used.

  • :default - A zero argument function, an {mod, fun, args} triple or a value. If no value is provided for the attribute on create, this value is used.

  • :description - An optional description for the attribute