Here is a piece exploring the "Uni Ecto" concept, focusing on how to bridge reactive Java (Uni) with Elixir's database logic, or how to conceptualize them in a polyglot architecture.
Uni.new() |> Ecto.insert(changeset) |> Uni.on_error(:insert, fn _step, error, ctx -> if error.reason == :invalid do # Log and return a default :ok, %MyApp.Useremail: "fallback@example.com" else :error, error end end)
test/support/repo.ex
config :uni_ecto_plugin, Repo, log_level: :info, global_filters: [:deleted_at], tenant_source: :header Use code with caution. 3. Implement in Your Schemas
def transfer_funds(from_id, to_id, amount) do Uni.new() |> Ecto.transaction(fn -> Uni.new() |> add_step(:decrement, Debit.run(from_id, amount)) |> add_step(:increment, Credit.run(to_id, amount)) |> Uni.execute() end) |> Uni.execute() end
def resolve(uni, _opts) do case MyApp.Fallback.get(uni) do nil -> :error, :uni_not_found record -> :ok, record end end
defmodule UniEctoPlugin.TestRepo do use Ecto.Repo, otp_app: :uni_ecto_plugin, adapter: Ecto.Adapters.Postgres end
You achieve the same result as any dedicated plugin would provide. Remember to always enforce uniqueness at the , not just in validations, to ensure your data remains consistent even under high concurrency.
5 thoughts on “Export the results of best practice analyzer from all models”
[exclusive] - Uni Ecto Plugin
Here is a piece exploring the "Uni Ecto" concept, focusing on how to bridge reactive Java (Uni) with Elixir's database logic, or how to conceptualize them in a polyglot architecture.
Uni.new() |> Ecto.insert(changeset) |> Uni.on_error(:insert, fn _step, error, ctx -> if error.reason == :invalid do # Log and return a default :ok, %MyApp.Useremail: "fallback@example.com" else :error, error end end)
test/support/repo.ex
config :uni_ecto_plugin, Repo, log_level: :info, global_filters: [:deleted_at], tenant_source: :header Use code with caution. 3. Implement in Your Schemas
def transfer_funds(from_id, to_id, amount) do Uni.new() |> Ecto.transaction(fn -> Uni.new() |> add_step(:decrement, Debit.run(from_id, amount)) |> add_step(:increment, Credit.run(to_id, amount)) |> Uni.execute() end) |> Uni.execute() end uni ecto plugin
def resolve(uni, _opts) do case MyApp.Fallback.get(uni) do nil -> :error, :uni_not_found record -> :ok, record end end
defmodule UniEctoPlugin.TestRepo do use Ecto.Repo, otp_app: :uni_ecto_plugin, adapter: Ecto.Adapters.Postgres end Here is a piece exploring the "Uni Ecto"
You achieve the same result as any dedicated plugin would provide. Remember to always enforce uniqueness at the , not just in validations, to ensure your data remains consistent even under high concurrency.
hi Ake,
Thanks for the comment! Yes that’s something I added myself in the extracted JSON rule file, you can either add it too or remove the M code part but if you’re not sure where to remove it I’d advise to add the [severity] in the file like I explained in the post: Here is an example of my rule description: “[Performance] [2] Do not use floating point data types” where [2] is the severity.
hi
i have an issue.
i’ve installed TE 2 and have a model.bim file on my machine and already downloaded bpa.json. but when I run the script in powershell I face this error:
TabularEditor.exe : The term ‘TabularEditor.exe’ is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:2 char:1
+ TabularEditor.exe “d:\Model.bim” -A > bparesults.txt
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (TabularEditor.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
hi Mahdi,
Can you copy/paste your script here