You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now we can add the data layer to our resources. The basic configuration for a resource requires the `d:AshSqlite.sqlite|table` and the `d:AshSqlite.sqlite|repo`.
@@ -160,6 +185,21 @@ Now we can add the data layer to our resources. The basic configuration for a re
160
185
end
161
186
```
162
187
188
+
189
+
And finaly link the application in your
190
+
191
+
```elixir
192
+
# in mix.exs
193
+
...
194
+
defapplicationdo
195
+
[
196
+
mod: {Helpdesk.Application, []},
197
+
...
198
+
]
199
+
end
200
+
...
201
+
```
202
+
163
203
### Create the database and tables
164
204
165
205
First, we'll create the database with `mix ash_sqlite.create`.
@@ -187,44 +227,58 @@ mix ash_sqlite.migrate
187
227
188
228
### Try it out
189
229
190
-
And now we're ready to try it out! Run the following in iex:
230
+
And now we're ready to try it out! Start iex with:
231
+
232
+
```bash
233
+
iex -S mix
234
+
```
191
235
192
236
Lets create some data. We'll make a representative and give them some open and some closed tickets.
And, naturally, now that we are storing this in sqlite, this database is persisted even if we stop/start our application. The nice thing, however, is that this was the _exact_ same code that we ran against our resources when they were backed by ETS.
@@ -243,9 +297,14 @@ And, naturally, now that we are storing this in sqlite, this database is persist
243
297
Simple calculation for Ticket which adds a concatenation of state and subject:
244
298
245
299
```
246
-
calculations do
247
-
calculate :status_subject, :string,
248
-
expr("#{status}: #{subject}")
300
+
# in lib/helpdesk/support/ticket.ex
301
+
defmodule Helpdesk.Support.Ticket do
302
+
...
303
+
calculations do
304
+
calculate :status_subject, :string,
305
+
expr("#{status}: #{subject}")
306
+
end
307
+
249
308
end
250
309
```
251
310
@@ -254,14 +313,14 @@ Testing of this feature can be done via iex:
254
313
```
255
314
Ash.Query
256
315
Helpdesk.Support.Ticket
257
-
|> Ash.Query.filter(status == :open)
258
-
|> Ash.Query.load(:status_subject)
259
-
|> Ash.read!()
316
+
|> Ash.Query.filter(status == :open)
317
+
|> Ash.Query.load(:status_subject)
318
+
|> Ash.read!()
260
319
```
261
320
262
321
### Aggregates
263
322
264
-
As stated in [what-is-ash-sqlite](https://hexdocs.pm/ash_sqlite/getting-started-with-ash-sqlite.html#steps),
323
+
As stated in [what-is-ash-sqlite](https://hexdocs.pm/ash_sqlite/getting-started-with-ash-sqlite.html#steps),
265
324
**The main feature missing is Aggregate support.**.
266
325
267
326
In order to use these consider using [ash_postgres](https://github.com/ash-project/ash_postgres) or
0 commit comments