# `Ash.Resource`
[🔗](https://github.com/ash-project/ash/blob/v3.17.0/lib/ash/resource.ex#L5)

A resource is a static definition of an entity in your system.

[Resource DSL documentation](dsl-ash-resource.html)

### Options

* `:simple_notifiers` (list of module that adopts `Ash.Notifier`) - Notifiers with no DSL.

* `:validate_domain_inclusion?` (`t:boolean/0`) - Whether or not to validate that this resource is included in a domain. The default value is `true`.

* `:primary_read_warning?` (`t:boolean/0`) - Set to `false` to silence warnings about arguments, preparations and filters on the primary read action. The default value is `true`.

* `:domain` (module that adopts `Ash.Domain`) - The domain to use when interacting with this resource. Also sets defaults for various options that ask for a domain.

* `:embed_nil_values?` (`t:boolean/0`) - Whether or not to include keys with `nil` values in an embedded representation. Has no effect unless resource is an embedded resource. The default value is `true`.

* `:extensions` (list of module that adopts `Spark.Dsl.Extension`) - A list of DSL extensions to add to the `Spark.Dsl`

* `:data_layer` (module that adopts `Ash.DataLayer`) - data_layer extensions to add to the `Spark.Dsl` The default value is `Ash.DataLayer.Simple`.

* `:authorizers` (one or a list of module that adopts `Ash.Authorizer`) - authorizers extensions to add to the `Spark.Dsl` The default value is `[]`.

* `:notifiers` (one or a list of module that adopts `Ash.Notifier`) - notifiers extensions to add to the `Spark.Dsl` The default value is `[]`.

* `:otp_app` (`t:atom/0`) - The otp_app to use for any application configurable options

* `:fragments` (list of `t:module/0`) - Fragments to include in the `Spark.Dsl`. See the fragments guide for more.

# `record`

```elixir
@type record() :: struct()
```

# `t`

```elixir
@type t() :: module()
```

# `get_metadata`

```elixir
@spec get_metadata(record(), atom() | [atom()]) :: term()
```

# `loaded?`

```elixir
@spec loaded?(
  nil | [record()] | record() | Ash.Page.page(),
  atom() | Ash.Query.Calculation.t() | Ash.Query.Aggregate.t() | [atom()],
  opts :: Keyword.t()
) :: boolean()
```

Returns true if the load or path to load has been loaded

## Options

- `lists`: set to `:any` to have this return true if any record in a list that appears has the value loaded. Default is `:all`.
- `unknown`: set to `true` to have unknown paths (like nil values or non-resources) return true. Defaults to `false`
- `strict?`: set to `true` to return false if a calculation with arguments is being checked

# `put_metadata`

```elixir
@spec put_metadata(record(), atom(), term()) :: record()
```

# `selected?`

Returns true if the given field has been selected on a record

## Options

- `forbidden_means_selected?`: set to `true` to return `true` if the field is marked as forbidden

# `set_metadata`

```elixir
@spec set_metadata(record(), map()) :: record()
```

# `timestamps`
*macro* 

Defines create and update timestamp attributes.

Shorthand for `d:Ash.Resource.Dsl.attributes.create_timestamp` and
`d:Ash.Resource.Dsl.attributes.update_timestamp` with the attribute names
`:inserted_at` and `:updated_at` respectively.  Any options passed to this
helper are passed to both timestamp macros.

# `unload`

```elixir
@spec unload(
  nil | [record()] | record() | Ash.Page.page(),
  atom() | [atom()]
) :: nil | [record()] | record() | Ash.Page.page()
```

Sets a loaded key or path to a key back to its original unloaded stated

# `unload_many`

```elixir
@spec unload_many(
  nil | [record()] | record() | Ash.Page.page(),
  [atom()] | [[atom()]]
) :: nil | [record()] | record() | Ash.Page.page()
```

Sets a list of loaded key or paths to a key back to their original unloaded stated

---

*Consult [api-reference.md](api-reference.md) for complete listing*
