documentation/dsls/DSL-AshEvents.EventLog.md

<!--
This file was generated by Spark. Do not edit it by hand.
-->
# AshEvents.EventLog

Extension to use on the Ash.Resource that will persist events.


## event_log


### Nested DSLs
 * [persist_actor_primary_key](#event_log-persist_actor_primary_key)


### Examples
```
event_log do
  clear_records_for_replay MyApp.Events.ClearAllRecords
  record_id_type :integer # (default is :uuid)
  persist_actor_primary_key :user_id, MyApp.Accounts.User
  persist_actor_primary_key :system_actor, MyApp.SystemActor, attribute_type: :string
end

```




### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`clear_records_for_replay`](#event_log-clear_records_for_replay){: #event_log-clear_records_for_replay } | `module` |  | A module with the AshEvents.ClearRecords-behaviour, that is expected to clear all records before an event replay. |
| [`record_id_type`](#event_log-record_id_type){: #event_log-record_id_type } | `any` | `:uuid` | The type of the primary key used by the system, which will be the type of the `record_id`-field on the events. Defaults to :uuid. |



### event_log.persist_actor_primary_key
```elixir
persist_actor_primary_key name, destination
```


Store the actor's primary key in the event if an actor is set, and the actor matches the resource type. You can define an entry for each actor type.



### Examples
```
persist_actor_primary_key :user_id, MyApp.Accounts.User
```

```
persist_actor_primary_key :system_actor, MyApp.SystemActor
```



### Arguments

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`name`](#event_log-persist_actor_primary_key-name){: #event_log-persist_actor_primary_key-name .spark-required} | `atom` |  | The name of the field to use for the actor primary_key (e.g. :user_id) |
| [`destination`](#event_log-persist_actor_primary_key-destination){: #event_log-persist_actor_primary_key-destination } | `module` |  | The resource of the actor (e.g. MyApp.Accounts.User) |
### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`allow_nil?`](#event_log-persist_actor_primary_key-allow_nil?){: #event_log-persist_actor_primary_key-allow_nil? } | `boolean` | `true` | Whether this attribute can be nil. If false, the attribute will be required. |
| [`attribute_type`](#event_log-persist_actor_primary_key-attribute_type){: #event_log-persist_actor_primary_key-attribute_type } | `any` | `:uuid` | The type of the generated attribute. See `Ash.Type` for more. |
| [`public?`](#event_log-persist_actor_primary_key-public?){: #event_log-persist_actor_primary_key-public? } | `boolean` | `false` | Whether this relationship should be included in public interfaces |





### Introspection

Target: `AshEvents.EventLog.PersistActorPrimaryKey`




## replay_overrides


### Nested DSLs
 * [replay_override](#replay_overrides-replay_override)
   * route_to





### replay_overrides.replay_override
```elixir
replay_override event_resource, event_action
```


Overrides the default event replay behavior for a specific resource action.

### Nested DSLs
 * [route_to](#replay_overrides-replay_override-route_to)


### Examples
```
replay_overrides do
  replay_override MyApp.Accounts.User, :create do
    versions [1]
    route_to MyApp.Accounts.User, :create_v1
  end
end

```



### Arguments

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`event_resource`](#replay_overrides-replay_override-event_resource){: #replay_overrides-replay_override-event_resource .spark-required} | `atom` |  | The name of the resource stored in the event, that you want to match on. |
| [`event_action`](#replay_overrides-replay_override-event_action){: #replay_overrides-replay_override-event_action .spark-required} | `atom` |  | The name of the action stored in the event, that you want to match on. |
### Options

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`versions`](#replay_overrides-replay_override-versions){: #replay_overrides-replay_override-versions .spark-required} | `list(integer)` |  | A list of event versions to match on. |


### replay_overrides.replay_override.route_to
```elixir
route_to resource, action
```


Routes the event to a different action.






### Arguments

| Name | Type | Default | Docs |
|------|------|---------|------|
| [`resource`](#replay_overrides-replay_override-route_to-resource){: #replay_overrides-replay_override-route_to-resource .spark-required} | `atom` |  |  |
| [`action`](#replay_overrides-replay_override-route_to-action){: #replay_overrides-replay_override-route_to-action .spark-required} | `atom` |  |  |















<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>