Skip to content

Commit

Permalink
Add information about primitive_structs config to README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Munat committed May 19, 2020
1 parent 4745cf3 commit 3f54981
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,36 @@ config :ex_audit,
]
```

Optionally, you can tell ExAudit to treat certain structs as primitives and not record internal changes for the
struct. Add these under the key `:primitive_structs` in your config. So for example, if you configured `Date` to be treated as a primitive:

```elixir
config :ex_audit,
ecto_repos: [ExAudit.Test.Repo],
version_schema: ExAudit.Test.Version,
tracked_schemas: [
ExAudit.Test.User,
ExAudit.Test.BlogPost,
ExAudit.Test.BlogPost.Section,
ExAudit.Test.Comment
],
primitive_structs: [
Date
]
```

then the patch would record the entire Date struct as a change:

```elixir
{:primitive_change, ~D[2000-01-01], ~D[2000-01-18]}
```

instead of descending into the struct to find the individual part that changed:

```elixir
{:changed, %{day: {:changed, {:primitive_change, 1, 18}}}}
```

### Version Schema and Migration

You need to copy the migration and the schema module for the versions table. This allows you to add custom fields
Expand Down

0 comments on commit 3f54981

Please sign in to comment.