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

Commit4c072b8

Browse files
add concept of postgres_table
1 parent864f83c commit4c072b8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

‎lib/ash_postgres.ex‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule AshPostgres do
1414
]
1515
)
1616

17-
aliasAsh.Filter.{And,Eq,Filter,In,NotEq,NotIn,Or}
17+
aliasAsh.Filter.{And,Eq,In,NotEq,NotIn,Or}
1818

1919
@moduledoc"""
2020
A postgres data layer that levereges Ecto's postgres tools.
@@ -101,7 +101,8 @@ defmodule AshPostgres do
101101
end
102102

103103
@impltrue
104-
defresource_to_query(resource),do:Ecto.Queryable.to_query(resource)
104+
defresource_to_query(resource),
105+
do:Ecto.Queryable.to_query({resource.postgres_table(),resource})
105106

106107
@impltrue
107108
defcreate(resource,changeset)do
@@ -111,6 +112,9 @@ defmodule AshPostgres do
111112
action->action
112113
end)
113114

115+
changeset=
116+
Map.update!(changeset,:__meta__,&Map.put(&1,:source,resource.postgres_table()))
117+
114118
repo(resource).insert(changeset)
115119
rescue
116120
e->
@@ -125,6 +129,14 @@ defmodule AshPostgres do
125129
{:error,e}
126130
end
127131

132+
@impltrue
133+
defdestroy(%resource{}=record)do
134+
repo(resource).delete(record)
135+
rescue
136+
e->
137+
{:error,e}
138+
end
139+
128140
@impltrue
129141
defsort(query,sort,_resource)do
130142
{:ok,
@@ -134,6 +146,7 @@ defmodule AshPostgres do
134146
end
135147

136148
@impltrue
149+
137150
# TODO: I have learned from experience that no single approach here
138151
# will be a one-size-fits-all. We need to either use complexity metrics,
139152
# hints from the interface, or some other heuristic to do our best to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp