mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
chore: add getting started guide
This commit is contained in:
parent
88999f27fd
commit
ea42601a4e
7 changed files with 148 additions and 307 deletions
26
README.md
26
README.md
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
All documentation is contained in the generated hex documentation located [here](https://hexdocs.pm/ash). Head there for installation and usage information. What follows is only a brief introduction to Ash.
|
||||||
|
|
||||||
Traditional MVC Frameworks (Rails, Django, .Net, Phoenix, etc) leave it up to the user to build the glue between requests for data (HTTP requests in various forms as well as server-side domain logic) and their respective ORMs. In that space, there is an incredible amount of boilerplate code that must get written from scratch for each application (authentication, authorization, sorting, filtering, sideloading relationships, serialization, etc).
|
Traditional MVC Frameworks (Rails, Django, .Net, Phoenix, etc) leave it up to the user to build the glue between requests for data (HTTP requests in various forms as well as server-side domain logic) and their respective ORMs. In that space, there is an incredible amount of boilerplate code that must get written from scratch for each application (authentication, authorization, sorting, filtering, sideloading relationships, serialization, etc).
|
||||||
|
|
||||||
Ash is an opinionated yet configurable framework designed to reduce boilerplate in an Elixir application. Ash does this by providing a layer of abstraction over your system's data layer(s) with `Resources`. It is designed to be used in conjunction with a phoenix application, or on its own.
|
Ash is an opinionated yet configurable framework designed to reduce boilerplate in an Elixir application. Ash does this by providing a layer of abstraction over your system's data layer(s) with `Resources`. It is designed to be used in conjunction with a phoenix application, or on its own.
|
||||||
|
@ -17,30 +19,6 @@ To start using Ash, first declare your `Resources` using the Ash `Resource` DSL.
|
||||||
|
|
||||||
Ash is an open-source project and draws inspiration from similar ideas in other frameworks and concepts. The goal of Ash is to lower the barrier to adopting and using Elixir and Phoenix, and in doing so help these amazing communities attract new developers, projects, and companies.
|
Ash is an open-source project and draws inspiration from similar ideas in other frameworks and concepts. The goal of Ash is to lower the barrier to adopting and using Elixir and Phoenix, and in doing so help these amazing communities attract new developers, projects, and companies.
|
||||||
|
|
||||||
## Example Resource
|
|
||||||
|
|
||||||
```elixir
|
|
||||||
defmodule Post do
|
|
||||||
use Ash.Resource
|
|
||||||
use AshJsonApi.JsonApiResource
|
|
||||||
use Ash.DataLayer.Postgres
|
|
||||||
|
|
||||||
actions do
|
|
||||||
read :default
|
|
||||||
|
|
||||||
create :default
|
|
||||||
end
|
|
||||||
|
|
||||||
attributes do
|
|
||||||
attribute :name, :string
|
|
||||||
end
|
|
||||||
|
|
||||||
relationships do
|
|
||||||
belongs_to :author, Author
|
|
||||||
end
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
## Creating a new release of Ash
|
## Creating a new release of Ash
|
||||||
|
|
||||||
- check out the repository locally
|
- check out the repository locally
|
||||||
|
|
Binary file not shown.
|
@ -1,281 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="-195 -61 1303 729" width="1303" height="729">
|
|
||||||
<defs>
|
|
||||||
<font-face font-family="Helvetica Neue" font-size="16" panose-1="2 0 5 3 0 0 0 2 0 4" units-per-em="1000" underline-position="-100" underline-thickness="50" slope="0" x-height="517" cap-height="714" ascent="951.9958" descent="-212.99744" font-weight="400">
|
|
||||||
<font-face-src>
|
|
||||||
<font-face-name name="HelveticaNeue"/>
|
|
||||||
</font-face-src>
|
|
||||||
</font-face>
|
|
||||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
|
||||||
<g>
|
|
||||||
<path d="M 8 0 L 0 -3 L 0 3 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
</marker>
|
|
||||||
</defs>
|
|
||||||
<metadata> Produced by OmniGraffle 7.7.1
|
|
||||||
<dc:date>2019-12-07 22:45:52 +0000</dc:date>
|
|
||||||
</metadata>
|
|
||||||
<g id="Canvas_1" fill-opacity="1" stroke-dasharray="none" stroke="none" stroke-opacity="1" fill="none">
|
|
||||||
<title>Canvas 1</title>
|
|
||||||
<rect fill="white" x="-195" y="-61" width="1303" height="729"/>
|
|
||||||
<g id="Canvas_1: Layer 1">
|
|
||||||
<title>Layer 1</title>
|
|
||||||
<g id="Graphic_90">
|
|
||||||
<rect x="798" y="17" width="309" height="638" fill="white"/>
|
|
||||||
<rect x="798" y="17" width="309" height="638" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_11">
|
|
||||||
<rect x="-194" y="-23" width="949" height="690.5" fill="white"/>
|
|
||||||
<rect x="-194" y="-23" width="949" height="690.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_82">
|
|
||||||
<rect x="93" y="-7" width="382" height="334.5" fill="white"/>
|
|
||||||
<rect x="93" y="-7" width="382" height="334.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_22">
|
|
||||||
<rect x="93" y="340" width="387" height="315" fill="white"/>
|
|
||||||
<rect x="93" y="340" width="387" height="315" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_39">
|
|
||||||
<rect x="859" y="287" width="198" height="136" fill="white"/>
|
|
||||||
<rect x="859" y="287" width="198" height="136" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(864 345.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="25.992" y="15">Postgres Database</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_40">
|
|
||||||
<rect x="859" y="461" width="198" height="136" fill="white"/>
|
|
||||||
<rect x="859" y="461" width="198" height="136" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(864 519.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="31.016" y="15">MySQL Database</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_41">
|
|
||||||
<rect x="859" y="89.5" width="198" height="136" fill="white"/>
|
|
||||||
<rect x="859" y="89.5" width="198" height="136" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(864 148.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="58.152" y="15">Stripe API</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_81">
|
|
||||||
<text transform="translate(215 -55.224)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x=".236" y="15">Phoenix Application</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_92">
|
|
||||||
<text transform="translate(909.5 -13.223999)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x=".196" y="15">Data Sources</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_93">
|
|
||||||
<rect x="492" y="7.5" width="250" height="619.5" fill="white"/>
|
|
||||||
<rect x="492" y="7.5" width="250" height="619.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_96">
|
|
||||||
<rect x="113" y="35" width="198" height="273" fill="white"/>
|
|
||||||
<rect x="113" y="35" width="198" height="273" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_97">
|
|
||||||
<rect x="117" y="374" width="198" height="267" fill="white"/>
|
|
||||||
<rect x="117" y="374" width="198" height="267" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_25">
|
|
||||||
<rect x="526" y="483" width="182" height="89" fill="white"/>
|
|
||||||
<rect x="526" y="483" width="182" height="89" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(531 518.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="50.72" y="15">Comment</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_18">
|
|
||||||
<text transform="translate(231 7.276001)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x=".312" y="15">Ash Api: AdminApi</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_70">
|
|
||||||
<rect x="322" y="120.5" width="144" height="94" fill="white"/>
|
|
||||||
<rect x="322" y="120.5" width="144" height="94" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(327 158.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="53.368" y="15">Ash</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_71">
|
|
||||||
<rect x="326.5" y="461" width="144" height="94" fill="white"/>
|
|
||||||
<rect x="326.5" y="461" width="144" height="94" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(331.5 498.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="53.368" y="15">Ash</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_73">
|
|
||||||
<line x1="470.5" y1="514.4256" x2="516.1392" y2="518.4987" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_57">
|
|
||||||
<rect x="146" y="65" width="144" height="94" fill="white"/>
|
|
||||||
<rect x="146" y="65" width="144" height="94" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(151 102.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="24.472" y="15">AshJsonApi</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_62">
|
|
||||||
<rect x="146" y="533" width="144" height="94" fill="white"/>
|
|
||||||
<rect x="146" y="533" width="144" height="94" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(151 570.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="20.616" y="15">AshGraphQL</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_115">
|
|
||||||
<rect x="146" y="412.5" width="144" height="94" fill="white"/>
|
|
||||||
<rect x="146" y="412.5" width="144" height="94" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(151 450.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="24.472" y="15">AshJsonApi</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_83">
|
|
||||||
<line x1="290" y1="134.70455" x2="312.5583" y2="141.8181" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_84">
|
|
||||||
<text transform="translate(223.5 345.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x=".052" y="15">Ash Api: UserApi</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_116">
|
|
||||||
<line x1="290" y1="478.84626" x2="316.93913" y2="486.08475" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_86">
|
|
||||||
<line x1="290" y1="551.2798" x2="317.30457" y2="540.3882" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_87">
|
|
||||||
<rect x="146" y="180" width="144" height="94" fill="white"/>
|
|
||||||
<rect x="146" y="180" width="144" height="94" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(151 217.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="36.048" y="15">Elixir Api</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_88">
|
|
||||||
<line x1="290" y1="202.6591" x2="312.62144" y2="195.0115" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_99">
|
|
||||||
<text transform="translate(151 40.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="31.744" y="15">Interfaces</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_101">
|
|
||||||
<text transform="translate(579 54.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x=".072" y="15">Resources</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_108">
|
|
||||||
<rect x="-182" y="89.5" width="250" height="441.5" fill="white"/>
|
|
||||||
<rect x="-182" y="89.5" width="250" height="441.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_104">
|
|
||||||
<rect x="-157" y="163.5" width="204" height="110.5" fill="white"/>
|
|
||||||
<rect x="-157" y="163.5" width="204" height="110.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(-152 209.526)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="27.656" y="15">Custom Controllers</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_105">
|
|
||||||
<line x1="47" y1="221.83242" x2="136.10452" y2="224.52514" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_106">
|
|
||||||
<rect x="-157" y="280.75" width="204" height="110.5" fill="white"/>
|
|
||||||
<rect x="-157" y="280.75" width="204" height="110.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(-152 326.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="66.48" y="15">Emailers</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_141">
|
|
||||||
<text transform="translate(-117 126.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x=".216" y="15">Application Code</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_110">
|
|
||||||
<rect x="-157" y="404.25" width="204" height="110.5" fill="white"/>
|
|
||||||
<rect x="-157" y="404.25" width="204" height="110.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(-152 450.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="39.056" y="15">Scheduled Jobs</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_112">
|
|
||||||
<line x1="47" y1="295.27473" x2="136.80576" y2="259.4182" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_113">
|
|
||||||
<line x1="9.874194" y1="404.25" x2="155.27584" y2="280.41893" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_121">
|
|
||||||
<text transform="translate(149 379.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="31.744" y="15">Interfaces</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_123">
|
|
||||||
<rect x="526" y="360" width="182" height="89" fill="white"/>
|
|
||||||
<rect x="526" y="360" width="182" height="89" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(531 395.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="69.704" y="15">Post</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_124">
|
|
||||||
<rect x="526" y="236.5" width="182" height="89" fill="white"/>
|
|
||||||
<rect x="526" y="236.5" width="182" height="89" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(531 271.776)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="62.144" y="15">Author</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_125">
|
|
||||||
<rect x="526" y="113" width="182" height="89" fill="white"/>
|
|
||||||
<rect x="526" y="113" width="182" height="89" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(531 148.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="51.032" y="15">Paycheck</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_126">
|
|
||||||
<line x1="466" y1="164.2713" x2="516.10994" y2="162.02422" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_127">
|
|
||||||
<line x1="466" y1="204.14574" x2="520.7453" y2="232.0094" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_130">
|
|
||||||
<line x1="443.7401" y1="461" x2="567.30076" y2="332.63262" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_132">
|
|
||||||
<line x1="470.5" y1="473.89474" x2="517.053" y2="451.8433" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_135">
|
|
||||||
<line x1="708" y1="527.9003" x2="849.1001" y2="528.52097" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_136">
|
|
||||||
<line x1="708" y1="157.5" x2="849.1" y2="157.5" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_137">
|
|
||||||
<line x1="708" y1="300.7478" x2="849.3252" y2="331.4166" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_138">
|
|
||||||
<line x1="708" y1="437.72434" x2="849.7004" y2="489.45954" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_142">
|
|
||||||
<rect x="-180.5" y="544.5" width="248.5" height="110.5" fill="white"/>
|
|
||||||
<rect x="-180.5" y="544.5" width="248.5" height="110.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(-175.5 590.526)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="39.09" y="15">User Facing Front End</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_143">
|
|
||||||
<line x1="51.78788" y1="544.5" x2="137.18571" y2="500.828" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Line_144">
|
|
||||||
<line x1="68" y1="590.8022" x2="136.12557" y2="585.89615" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
<g id="Graphic_146">
|
|
||||||
<rect x="-181.25" y="-7" width="248.5" height="89" fill="white"/>
|
|
||||||
<rect x="-181.25" y="-7" width="248.5" height="89" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
<text transform="translate(-176.25 28.276)" fill="black">
|
|
||||||
<tspan font-family="Helvetica Neue" font-size="16" font-weight="400" fill="black" x="54.778" y="15">Admin Dashboard</tspan>
|
|
||||||
</text>
|
|
||||||
</g>
|
|
||||||
<g id="Line_147">
|
|
||||||
<line x1="67.25" y1="71.160455" x2="136.44444" y2="89.90586" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 17 KiB |
144
documentation/getting_started.md
Normal file
144
documentation/getting_started.md
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
# Getting Started
|
||||||
|
|
||||||
|
## Creating an application
|
||||||
|
|
||||||
|
For information on creating a new Elixir application, see [this guide](https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html)
|
||||||
|
|
||||||
|
## Add Ash
|
||||||
|
|
||||||
|
Add `ash` to your dependencies in `mix.exs`. The latest version can be found by running `mix hex.info ash`.
|
||||||
|
|
||||||
|
## Create an Ash API
|
||||||
|
|
||||||
|
Create an API module. This will be your primary way to interact with your Ash resources. We recommend `lib/api.ex` for simple setups.
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
defmodule MyApp.Api do
|
||||||
|
use Ash.Api
|
||||||
|
|
||||||
|
resources do
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, add `MyApp.Api` to your `application.ex`'s start function, which should look something like this:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
def start(_type, _args) do
|
||||||
|
children = [
|
||||||
|
# Start the Ecto repository
|
||||||
|
MyApp.Repo,
|
||||||
|
# Start the Telemetry supervisor
|
||||||
|
MyApp.Telemetry,
|
||||||
|
# Start the PubSub system
|
||||||
|
{Phoenix.PubSub, name: MyApp.PubSub},
|
||||||
|
# Start the Endpoint (http/https)
|
||||||
|
MyApp.Endpoint,
|
||||||
|
MyApp.Api # <- Add your API here
|
||||||
|
]
|
||||||
|
...
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Create a resource
|
||||||
|
|
||||||
|
A resource is the primary entity in Ash. Your Api module ties your resources together and gives them an interface, but the vast majority if your configuration will live in a resource. In your typical setup, you might have a resource per database table. For those already familiar with ecto, a resource and an ecto schema are very similar. In fact, all resources define an ecto schema under the hood. This can be leveraged when you need to do things that are not yet implemented or fall outside of the scope of Ash. Here are a few examples:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
defmodule MyApp.Tweet do
|
||||||
|
use Ash.Resource
|
||||||
|
|
||||||
|
attributes do
|
||||||
|
attribute :id, :uuid do
|
||||||
|
# All ash resources currently require a primary key
|
||||||
|
# Eventually, we will add good defaults and/or allow
|
||||||
|
# for a global configuration of your default primary key
|
||||||
|
primary_key? true
|
||||||
|
allow_nil? false
|
||||||
|
writable? false
|
||||||
|
default &Ecto.UUID.generate/0
|
||||||
|
end
|
||||||
|
|
||||||
|
attribute :body, :string do
|
||||||
|
allow_nil? false
|
||||||
|
constraints [max_length: 255]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Alternatively, you can use the keyword list syntax
|
||||||
|
# `{:constant, <value>}` is how you set a default
|
||||||
|
# You can also set functional defaults, via passing in a zero
|
||||||
|
# argument function or an MFA
|
||||||
|
attribute :public, :boolean, allow_nil?: false, default: {:constant, false}
|
||||||
|
|
||||||
|
create_timestamp :created_at #This is set on create
|
||||||
|
update_timestamp :updated_at #This is updated on all updates
|
||||||
|
|
||||||
|
# `create_timestamp` above is just shorthand for:
|
||||||
|
attribute :created_at, :utc_datetime, writable?: false, default: &DateTime.utc_now/0
|
||||||
|
end
|
||||||
|
|
||||||
|
relationships do
|
||||||
|
belongs_to :user, MyApp.User
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defmodule MyApp.User do
|
||||||
|
use Ash.Resource
|
||||||
|
|
||||||
|
attributes do
|
||||||
|
attribute :email, :string, allow_nil?: false, constraints: [
|
||||||
|
match: ~r/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
relationships do
|
||||||
|
has_many :tweets, MyApp.Tweet, destination_field: :user_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add resources to your API
|
||||||
|
|
||||||
|
Alter your API like so:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
resources do
|
||||||
|
resource MyApp.User
|
||||||
|
resource MyApp.Tweet
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add your datalayer
|
||||||
|
|
||||||
|
Choose a datalayer, and see its documentation for configuring it:
|
||||||
|
|
||||||
|
- `Ash.DataLayer.Ets` - an [ets](https://erlang.org/doc/man/ets.html) datalayer only recommended for testing
|
||||||
|
- `Ash.DataLayer.Mnesia` - an [mnesia](https://erlang.org/doc/man/mnesia.html) datalayer, not optimized, but is backed by a file and works with distributed applications
|
||||||
|
- `AshPostgres.DataLayer` - a Postgres datalayer, currently the primary supported data layer
|
||||||
|
|
||||||
|
To add a datalayer, add it to the `use Ash.Resource` statement:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
use Ash.Resource,
|
||||||
|
data_layer: AshPostgres.DataLayer
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add actions to enable functionality
|
||||||
|
|
||||||
|
Currently, actions do not offer any customization, but eventually they will be the primary driver for adding specific interactions to your resource. For now, to enable all of them, add the following to your resource:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
actions do
|
||||||
|
create :default
|
||||||
|
read :default
|
||||||
|
update :default
|
||||||
|
destroy :default
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## See Ash documentation for the rest
|
||||||
|
|
||||||
|
- `Ash.Api` for what you can do with your resources.
|
||||||
|
- `Ash.Query` for the kinds of queries you can make.
|
||||||
|
- `Ash.Dsl` for the resource DSL documentation.
|
||||||
|
- `Ash.Api.Dsl` for the API DSL documentation.
|
|
@ -1,5 +1,6 @@
|
||||||
defmodule Ash do
|
defmodule Ash do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
|
Ash Framework
|
||||||
|
|
||||||
![Logo](https://github.com/ash-project/ash/blob/master/logos/cropped-for-header.png?raw=true)
|
![Logo](https://github.com/ash-project/ash/blob/master/logos/cropped-for-header.png?raw=true)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ defmodule Ash.Resource do
|
||||||
A resource is a static definition of an entity in your system.
|
A resource is a static definition of an entity in your system.
|
||||||
|
|
||||||
Resource DSL documentation: `Ash.Dsl`
|
Resource DSL documentation: `Ash.Dsl`
|
||||||
|
|
||||||
For more information on the resource DSL, see `Ash.Dsl`
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias Ash.Dsl.Extension
|
alias Ash.Dsl.Extension
|
||||||
|
|
1
mix.exs
1
mix.exs
|
@ -38,6 +38,7 @@ defmodule Ash.MixProject do
|
||||||
main: "Ash",
|
main: "Ash",
|
||||||
source_ref: "v#{@version}",
|
source_ref: "v#{@version}",
|
||||||
logo: "logos/small-logo.png",
|
logo: "logos/small-logo.png",
|
||||||
|
extras: ["documentation/getting_started.md"],
|
||||||
groups_for_modules: [
|
groups_for_modules: [
|
||||||
entrypoint: [
|
entrypoint: [
|
||||||
Ash,
|
Ash,
|
||||||
|
|
Loading…
Reference in a new issue