# Ash Framework: suggestion. add examples how to fall back to ecto

**URL:** <https://forum.devtalk.com/t/ash-framework-suggestion-add-examples-how-to-fall-back-to-ecto/184481>\
**Category:** PragProg Customers\
**Tags:** book-ash-framework, suggestion\
**Created:** [18 January 2025 01:09 UTC](https://forum.devtalk.com/t/ash-framework-suggestion-add-examples-how-to-fall-back-to-ecto/184481 "2025-01-18T01:09:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkuku](https://forum.devtalk.com/user_avatar/forum.devtalk.com/dkuku/32/1666_2.png) [@dkuku](https://forum.devtalk.com/u/dkuku)\
**Post date:** [18 January 2025 01:09 UTC](https://forum.devtalk.com/t/ash-framework-suggestion-add-examples-how-to-fall-back-to-ecto/184481/1 "2025-01-18T01:09:03Z")

</div>

I’ve worked through the book and it starts to click in my head. What’s missing for me are examples how to fallback to some lower level stuff like a custom ecto query with fragments. Sometimes some data needs to be fixed in bulk. It can’t be done in a single query, and the easiest way is to use ecto query in a recursive function that updates the data in smaller chunks in the background. It’s pretty simple using pure ecto, but I’m not sure how do do it using ash resources.

---

<div class="post-metadata">

**Author:** ![sevenseacat](https://forum.devtalk.com/user_avatar/forum.devtalk.com/sevenseacat/32/5897_2.png) [@sevenseacat](https://forum.devtalk.com/u/sevenseacat)\
**Post date:** [18 January 2025 07:22 UTC](https://forum.devtalk.com/t/ash-framework-suggestion-add-examples-how-to-fall-back-to-ecto/184481/2 "2025-01-18T07:22:27Z")

</div>

The good news is, you can always fall back to writing Ecto queries directly, as Ash resources are built on top of Ecto schemas. I tend to do this if I need to write data migrations - using resource actions there isn’t great because then the migrations need to be kept up to date (otherwise your app won’t compile).

I’ll have a think about this one, see if we can make a mention about it somewhere. Thanks for the feedback!

---

<div class="post-metadata">

**Author:** ![zachdaniel](https://forum.devtalk.com/user_avatar/forum.devtalk.com/zachdaniel/32/5862_2.png) [@zachdaniel](https://forum.devtalk.com/u/zachdaniel)\
**Post date:** [19 January 2025 19:25 UTC](https://forum.devtalk.com/t/ash-framework-suggestion-add-examples-how-to-fall-back-to-ecto/184481/3 "2025-01-19T19:25:04Z")

</div>

Also something to keep in mind:

Ash has support for fragments in its expression syntax just like Ecto.

```elixir
update :something do
  change atomic_update(:value, fragment("?..."))
end

```

Ash has support for bulk updates using `Ash.bulk_update`

```elixir
Resource 
|> Ash.Query.filter(name == "foo") 
|> Ash.bulk_update!(:action, %{a: 10})

```

and also generic actions.

```elixir
action :manual_stuff do
  argument :foo, :string, allow_nil?: false
  run YourActionImplementation
end

```

Generic actions can do anything internally including recursive calls back to functions in `Ash`
