Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8148ae

Browse files
committed
feat: update to latest ash
1 parent6661d30 commitf8148ae

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

‎lib/data_layer.ex‎

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,37 +122,25 @@ defmodule AshPostgres.DataLayer do
122122

123123
@impltrue
124124
defcreate(resource,changeset)do
125-
changeset=
126-
Map.update!(changeset,:action,fn
127-
:create->:insert
128-
action->action
129-
end)
130-
131-
changeset=
132-
Map.update!(changeset,:data,fndata->
133-
Map.update!(data,:__meta__,&Map.put(&1,:source,table(resource)))
134-
end)
135-
136-
repo(resource).insert(changeset)
125+
changeset.data
126+
|>Map.update!(:__meta__,&Map.put(&1,:source,table(resource)))
127+
|>ecto_changeset(changeset)
128+
|>repo(resource).insert()
137129
rescue
138130
e->
139131
{:error,e}
140132
end
141133

134+
defpecto_changeset(record,changeset)do
135+
Ecto.Changeset.change(record,changeset.attributes)
136+
end
137+
142138
@impltrue
143139
defupsert(resource,changeset)do
144-
changeset=
145-
Map.update!(changeset,:action,fn
146-
:create->:insert
147-
action->action
148-
end)
149-
150-
changeset=
151-
Map.update!(changeset,:data,fndata->
152-
Map.update!(data,:__meta__,&Map.put(&1,:source,table(resource)))
153-
end)
154-
155-
repo(resource).insert(changeset,
140+
changeset.data
141+
|>Map.update!(:__meta__,&Map.put(&1,:source,table(resource)))
142+
|>ecto_changeset(changeset)
143+
|>repo(resource).insert(
156144
on_conflict::replace_all,
157145
conflict_target:Ash.primary_key(resource)
158146
)
@@ -163,7 +151,10 @@ defmodule AshPostgres.DataLayer do
163151

164152
@impltrue
165153
defupdate(resource,changeset)do
166-
repo(resource).update(changeset)
154+
changeset.data
155+
|>Map.update!(:__meta__,&Map.put(&1,:source,table(resource)))
156+
|>ecto_changeset(changeset)
157+
|>repo(resource).update()
167158
rescue
168159
e->
169160
{:error,e}

‎mix.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defmodule AshPostgres.MixProject do
6161
[
6262
{:ecto_sql,"~> 3.4"},
6363
{:postgrex,">= 0.0.0"},
64-
{:ash,"~> 1.1.2"},
64+
{:ash,"~> 1.2.1"},
6565
{:git_ops,"~> 2.0.0",only::dev},
6666
{:ex_doc,"~> 0.22",only::dev,runtime:false},
6767
{:ex_check,"~> 0.11.0",only::dev},

‎mix.lock‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%{
2-
"ash":{:hex,:ash,"1.1.2","77cd65a3b79dfa56cebdf4d7318a970874c0166d19d84181ed49725c4e92207c",[:mix],[{:ecto,"~> 3.4",[hex::ecto,repo:"hexpm",optional:false]},{:ets,"~> 0.8.0",[hex::ets,repo:"hexpm",optional:false]},{:nimble_options,"~> 0.3.0",[hex::nimble_options,repo:"hexpm",optional:false]},{:picosat_elixir,"~> 0.1.4",[hex::picosat_elixir,repo:"hexpm",optional:false]}],"hexpm","37c44f5246c550a4d25c862d87bb3efdc2106a1ff54125bb5e64e96573239c4b"},
2+
"ash":{:hex,:ash,"1.2.1","27838bd2d3a4d57199225015b310972a2b3b4563f5dff57100bc3c06ac1b83a7",[:mix],[{:ecto,"~> 3.4",[hex::ecto,repo:"hexpm",optional:false]},{:ets,"~> 0.8.0",[hex::ets,repo:"hexpm",optional:false]},{:nimble_options,"~> 0.3.0",[hex::nimble_options,repo:"hexpm",optional:false]},{:picosat_elixir,"~> 0.1.4",[hex::picosat_elixir,repo:"hexpm",optional:false]}],"hexpm","f8d6fc1ae4bfeb9ab8ba72eff30f1d7b50cd5b9d379262a975fce1bbcbc01cd9"},
33
"bunt":{:hex,:bunt,"0.2.0","951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38",[:mix],[],"hexpm","7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
44
"certifi":{:hex,:certifi,"2.5.2","b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340",[:rebar3],[{:parse_trans,"~>3.3",[hex::parse_trans,repo:"hexpm",optional:false]}],"hexpm","3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"},
55
"connection":{:hex,:connection,"1.0.4","a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976",[:mix],[],"hexpm","4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp