Compare commits
30 commits
v0.4.1
...
v0.5.0-rc.
Author | SHA1 | Date | |
---|---|---|---|
3aa592c262 | |||
4379a15443 | |||
258c7df0a1 | |||
333403a7bd | |||
ac7de967e1 | |||
05aa2e673a | |||
f7df16cae5 | |||
ab7ebc5f64 | |||
95bbffb767 | |||
68fa5d87c5 | |||
313f0908c5 | |||
580d89002c | |||
12b4e77b99 | |||
fb8dcd9fe8 | |||
0455f5c4d9 | |||
d6dcf72ce8 | |||
1922576b2b | |||
3a0729bb74 | |||
1a5a0ae77a | |||
cd385ab538 | |||
1acc11e221 | |||
5a7a78f837 | |||
a502a31983 | |||
9d9aa0e5f9 | |||
6a7344edb6 | |||
8c26354241 | |||
63bcf500e2 | |||
262def5267 | |||
466b9d4d3b | |||
c02c99a3e9 |
16 changed files with 226 additions and 358 deletions
31
.drone.yml
31
.drone.yml
|
@ -49,7 +49,7 @@ steps:
|
|||
- .rebar3
|
||||
|
||||
- name: install dependencies
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
pull: "always"
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
|
@ -121,7 +121,7 @@ steps:
|
|||
- .rebar3
|
||||
|
||||
- name: mix compile
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -134,7 +134,7 @@ steps:
|
|||
- asdf mix compile --warnings-as-errors
|
||||
|
||||
- name: mix test
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -147,7 +147,7 @@ steps:
|
|||
- asdf mix test
|
||||
|
||||
- name: mix credo
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -160,7 +160,7 @@ steps:
|
|||
- asdf mix credo --strict
|
||||
|
||||
- name: mix hex.audit
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -173,7 +173,7 @@ steps:
|
|||
- asdf mix hex.audit
|
||||
|
||||
- name: mix format
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -186,7 +186,7 @@ steps:
|
|||
- asdf mix format --check-formatted
|
||||
|
||||
- name: mix spark.formatter
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -199,7 +199,7 @@ steps:
|
|||
- asdf mix spark.formatter --check
|
||||
|
||||
- name: mix spark.cheat_sheets
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -212,7 +212,7 @@ steps:
|
|||
- asdf mix spark.cheat_sheets --check
|
||||
|
||||
- name: mix deps.unlock
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -225,7 +225,7 @@ steps:
|
|||
- asdf mix deps.unlock --check-unused
|
||||
|
||||
- name: mix doctor
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -238,7 +238,7 @@ steps:
|
|||
- asdf mix doctor --full
|
||||
|
||||
- name: mix git_ops.check_message
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
environment:
|
||||
MIX_ENV: test
|
||||
HEX_HOME: /drone/src/.hex
|
||||
|
@ -252,7 +252,7 @@ steps:
|
|||
- asdf mix git_ops.check_message .last_commit_message
|
||||
|
||||
- name: mix git_ops.release
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
|
@ -293,7 +293,7 @@ steps:
|
|||
- fi
|
||||
|
||||
- name: build artifacts
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
@ -341,7 +341,7 @@ steps:
|
|||
settings:
|
||||
api_key:
|
||||
from_secret: DRONE_TOKEN
|
||||
base_url: https://code.harton.nz
|
||||
base_url: https://harton.dev
|
||||
files: artifacts/*.tar.gz
|
||||
checksum: sha256
|
||||
title: tag_subject
|
||||
|
@ -367,12 +367,11 @@ steps:
|
|||
commands:
|
||||
- mc alias set store $${S3_ENDPOINT} $${ACCESS_KEY} $${SECRET_KEY}
|
||||
- mc mb -p store/docs.harton.nz
|
||||
- mc anonymous set download store/docs.harton.nz
|
||||
- mc mirror --overwrite doc/ store/docs.harton.nz/$${DRONE_REPO}/$${DRONE_TAG}
|
||||
- mc mirror --overwrite doc/ store/docs.harton.nz/$${DRONE_REPO}
|
||||
|
||||
- name: hex release
|
||||
image: code.harton.nz/james/asdf_container:latest
|
||||
image: harton.dev/james/asdf_container:latest
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
erlang 26.1.1
|
||||
elixir 1.15.6
|
||||
erlang 26.2.3
|
||||
elixir 1.16.2-otp-26
|
||||
|
|
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -5,7 +5,14 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v0.4.1](https://code.harton.nz/james/ash_cubdb/compare/v0.4.0...v0.4.1) (2023-10-02)
|
||||
## [v0.5.0-rc.0](https://harton.dev/james/ash_cubdb/compare/v0.4.1...v0.5.0-rc.0) (2024-03-27)
|
||||
### Breaking Changes:
|
||||
|
||||
* Ash 3.0 support.
|
||||
|
||||
|
||||
|
||||
## [v0.4.1](https://harton.dev/james/ash_cubdb/compare/v0.4.0...v0.4.1) (2023-10-02)
|
||||
|
||||
|
||||
|
||||
|
@ -14,7 +21,7 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
* correctly enable filtering and sorting.
|
||||
|
||||
## [v0.4.0](https://code.harton.nz/james/ash_cubdb/compare/v0.3.1...v0.4.0) (2023-10-02)
|
||||
## [v0.4.0](https://harton.dev/james/ash_cubdb/compare/v0.3.1...v0.4.0) (2023-10-02)
|
||||
|
||||
|
||||
|
||||
|
@ -27,7 +34,7 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
* honour tenancy when updating.
|
||||
|
||||
## [v0.3.1](https://code.harton.nz/james/ash_cubdb/compare/v0.3.0...v0.3.1) (2023-10-02)
|
||||
## [v0.3.1](https://harton.dev/james/ash_cubdb/compare/v0.3.0...v0.3.1) (2023-10-02)
|
||||
|
||||
|
||||
|
||||
|
@ -36,7 +43,7 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
* enable sorting capability.
|
||||
|
||||
## [v0.3.0](https://code.harton.nz/james/ash_cubdb/compare/v0.2.0...v0.3.0) (2023-10-02)
|
||||
## [v0.3.0](https://harton.dev/james/ash_cubdb/compare/v0.2.0...v0.3.0) (2023-10-02)
|
||||
|
||||
|
||||
|
||||
|
@ -45,7 +52,7 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
* Support updating existing records.
|
||||
|
||||
## [v0.2.0](https://code.harton.nz/james/ash_cubdb/compare/v0.1.0...v0.2.0) (2023-09-29)
|
||||
## [v0.2.0](https://harton.dev/james/ash_cubdb/compare/v0.1.0...v0.2.0) (2023-09-29)
|
||||
|
||||
|
||||
|
||||
|
@ -54,7 +61,7 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
|
|||
|
||||
* `create` and `read` works.
|
||||
|
||||
## [v0.1.0](https://code.harton.nz/james/ash_cubdb/compare/v0.1.0...v0.1.0) (2023-08-07)
|
||||
## [v0.1.0](https://harton.dev/james/ash_cubdb/compare/v0.1.0...v0.1.0) (2023-08-07)
|
||||
|
||||
|
||||
|
||||
|
|
17
README.md
17
README.md
|
@ -1,6 +1,7 @@
|
|||
# AshCubDB
|
||||
|
||||
[![Build Status](https://drone.harton.nz/api/badges/james/ash_cubdb/status.svg?ref=refs/heads/main)](https://drone.harton.nz/cinder/cinder)
|
||||
[![Build Status](https://drone.harton.dev/api/badges/james/ash_cubdb/status.svg?ref=refs/heads/main)](https://drone.harton.dev/james/ash_cubdb)
|
||||
[![Hex.pm](https://img.shields.io/hexpm/v/ash_cubdb.svg)](https://hex.pm/packages/ash_cubdb)
|
||||
[![Hippocratic License HL3-FULL](https://img.shields.io/static/v1?label=Hippocratic%20License&message=HL3-FULL&labelColor=5e2751&color=bc8c3d)](https://firstdonoharm.dev/version/3/0/full.html)
|
||||
|
||||
An [Ash DataLayer](https://ash-hq.org/docs/module/ash/latest/ash-datalayer)
|
||||
|
@ -8,10 +9,10 @@ which adds support for [CubDB](https://hex.pm/packages/cubdb).
|
|||
|
||||
## Status
|
||||
|
||||
AshCubDb is still a work in progress. Feel free to give it a go.
|
||||
AshCubDb is still a work in progress. Feel free to give it a go.
|
||||
|
||||
| Feature | Status |
|
||||
|-------------------------|--------|
|
||||
| ----------------------- | ------ |
|
||||
| Create | ✅ |
|
||||
| Upsert (by primary key) | ✅ |
|
||||
| Upsert (by identity) | ❌ |
|
||||
|
@ -29,22 +30,26 @@ AshCubDb is still a work in progress. Feel free to give it a go.
|
|||
## Github Mirror
|
||||
|
||||
This repository is mirrored [on Github](https://github.com/jimsynz/ash_cubdb)
|
||||
from it's primary location [on my Forejo instance](https://code.harton.nz/james/ash_cubdb).
|
||||
from it's primary location [on my Forgejo instance](https://harton.dev/james/ash_cubdb).
|
||||
Feel free to raise issues and open PRs on Github.
|
||||
|
||||
## Installation
|
||||
|
||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||
AshCubDB is [available in Hex](https://hex.pm/packages/ash_cubdb), the package can be installed
|
||||
by adding `ash_cubdb` to your list of dependencies in `mix.exs`:
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
[
|
||||
{:ash_cubdb, "~> 0.4.1"}
|
||||
{:ash_cubdb, "~> 0.5.0-rc.0"}
|
||||
]
|
||||
end
|
||||
```
|
||||
|
||||
Documentation for the latest release can be found on
|
||||
[HexDocs](https://hexdocs.pm/ash_cubdb) and for the `main` branch on
|
||||
[docs.harton.nz](https://docs.harton.nz/james/ash_cubdb).
|
||||
|
||||
## License
|
||||
|
||||
This software is licensed under the terms of the
|
||||
|
|
|
@ -3,13 +3,13 @@ import Config
|
|||
config :git_ops,
|
||||
mix_project: Mix.Project.get!(),
|
||||
changelog_file: "CHANGELOG.md",
|
||||
repository_url: "https://code.harton.nz/james/ash_cubdb",
|
||||
repository_url: "https://harton.dev/james/ash_cubdb",
|
||||
manage_mix_version?: true,
|
||||
version_tag_prefix: "v",
|
||||
manage_readme_version: "README.md"
|
||||
|
||||
if Mix.env() in ~w[dev test]a do
|
||||
config :ash_cubdb, ash_apis: [Support.Api]
|
||||
config :ash_cubdb, ash_domains: [Support.Domain]
|
||||
config :ash_cubdb, debug_data_layer_capabilities?: true
|
||||
|
||||
config :spark, :formatter, remove_parens?: true
|
||||
|
|
|
@ -1,225 +0,0 @@
|
|||
<!--
|
||||
This file was generated by Spark. Do not edit it by hand.
|
||||
-->
|
||||
# DSL: AshCubDB.DataLayer
|
||||
|
||||
A CubDB data layer for Ash.
|
||||
|
||||
<!--- ash-hq-hide-start --> <!--- -->
|
||||
|
||||
## DSL Documentation
|
||||
|
||||
### Index
|
||||
|
||||
* cubdb
|
||||
|
||||
### Docs
|
||||
|
||||
## cubdb
|
||||
|
||||
CubDB data layer configuration.
|
||||
|
||||
|
||||
|
||||
|
||||
Examples:
|
||||
```
|
||||
cubdb do
|
||||
directory "/opt/storage/my_awesome_resource"
|
||||
auto_compact? true
|
||||
auto_file_sync? true
|
||||
name :my_awesome_resource
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
* `:directory` - The directory within which to store the CubDB data.
|
||||
If none is supplied, then one will be automatically generated in the
|
||||
`priv` directory of the parent OTP application.
|
||||
|
||||
* `:otp_app` (`t:atom/0`) - The OTP application in whose `priv` directory data should be stored.
|
||||
Only used if `directory` is not supplied. When not provided
|
||||
`Application.get_application/1` will be called for the resource.
|
||||
|
||||
* `:auto_compact?` (`t:boolean/0`) - Whether or not to automatically compact the CubDB database.
|
||||
See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-is-compaction) for more information. The default value is `true`.
|
||||
|
||||
* `:auto_file_sync?` (`t:boolean/0`) - Whether or not to automatically flush the buffer to disk on write.
|
||||
See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-does-file-sync-mean) The default value is `true`.
|
||||
|
||||
* `:name` (`t:atom/0`) - The name of the CubDB database.
|
||||
By default this is the name of the resource module, however in some
|
||||
(rare) circumstances you may wish to specifically name the database.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- ash-hq-hide-stop --> <!--- -->
|
||||
|
||||
|
||||
## cubdb
|
||||
CubDB data layer configuration.
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
```
|
||||
cubdb do
|
||||
directory "/opt/storage/my_awesome_resource"
|
||||
auto_compact? true
|
||||
auto_file_sync? true
|
||||
name :my_awesome_resource
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Options
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Default</th>
|
||||
<th colspan=2>Docs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a id="cubdb-directory" href="#cubdb-directory">
|
||||
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
|
||||
directory
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">nil | String.t</code>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
|
||||
</td>
|
||||
<td style="text-align: left" colspan=2>
|
||||
The directory within which to store the CubDB data.
|
||||
|
||||
If none is supplied, then one will be automatically generated in the
|
||||
`priv` directory of the parent OTP application.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a id="cubdb-otp_app" href="#cubdb-otp_app">
|
||||
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
|
||||
otp_app
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">atom</code>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
|
||||
</td>
|
||||
<td style="text-align: left" colspan=2>
|
||||
The OTP application in whose `priv` directory data should be stored.
|
||||
|
||||
Only used if `directory` is not supplied. When not provided
|
||||
`Application.get_application/1` will be called for the resource.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a id="cubdb-auto_compact?" href="#cubdb-auto_compact?">
|
||||
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
|
||||
auto_compact?
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">boolean</code>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">true</code>
|
||||
</td>
|
||||
<td style="text-align: left" colspan=2>
|
||||
Whether or not to automatically compact the CubDB database.
|
||||
|
||||
See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-is-compaction) for more information.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a id="cubdb-auto_file_sync?" href="#cubdb-auto_file_sync?">
|
||||
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
|
||||
auto_file_sync?
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">boolean</code>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">true</code>
|
||||
</td>
|
||||
<td style="text-align: left" colspan=2>
|
||||
Whether or not to automatically flush the buffer to disk on write.
|
||||
|
||||
See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-does-file-sync-mean)
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: left">
|
||||
<a id="cubdb-name" href="#cubdb-name">
|
||||
<span style="font-family: Inconsolata, Menlo, Courier, monospace;">
|
||||
name
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<code class="inline">atom</code>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
|
||||
</td>
|
||||
<td style="text-align: left" colspan=2>
|
||||
The name of the CubDB database.
|
||||
|
||||
By default this is the name of the resource module, however in some
|
||||
(rare) circumstances you may wish to specifically name the database.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
104
documentation/dsls/DSL:-AshCubDB.DataLayer.md
Normal file
104
documentation/dsls/DSL:-AshCubDB.DataLayer.md
Normal file
|
@ -0,0 +1,104 @@
|
|||
<!--
|
||||
This file was generated by Spark. Do not edit it by hand.
|
||||
-->
|
||||
# DSL: AshCubDB.DataLayer
|
||||
|
||||
A CubDB data layer for Ash.
|
||||
|
||||
<!--- ash-hq-hide-start --> <!--- -->
|
||||
|
||||
## DSL Documentation
|
||||
|
||||
### Index
|
||||
|
||||
* cubdb
|
||||
|
||||
### Docs
|
||||
|
||||
## cubdb
|
||||
|
||||
CubDB data layer configuration.
|
||||
|
||||
|
||||
|
||||
|
||||
Examples:
|
||||
```
|
||||
cubdb do
|
||||
directory "/opt/storage/my_awesome_resource"
|
||||
auto_compact? true
|
||||
auto_file_sync? true
|
||||
name :my_awesome_resource
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
* `:directory` - The directory within which to store the CubDB data.
|
||||
If none is supplied, then one will be automatically generated in the
|
||||
`priv` directory of the parent OTP application.
|
||||
|
||||
* `:otp_app` (`t:atom/0`) - The OTP application in whose `priv` directory data should be stored.
|
||||
Only used if `directory` is not supplied. When not provided
|
||||
`Application.get_application/1` will be called for the resource.
|
||||
|
||||
* `:auto_compact?` (`t:boolean/0`) - Whether or not to automatically compact the CubDB database.
|
||||
See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-is-compaction) for more information. The default value is `true`.
|
||||
|
||||
* `:auto_file_sync?` (`t:boolean/0`) - Whether or not to automatically flush the buffer to disk on write.
|
||||
See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-does-file-sync-mean) The default value is `true`.
|
||||
|
||||
* `:name` (`t:atom/0`) - The name of the CubDB database.
|
||||
By default this is the name of the resource module, however in some
|
||||
(rare) circumstances you may wish to specifically name the database.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- ash-hq-hide-stop --> <!--- -->
|
||||
|
||||
|
||||
## cubdb
|
||||
CubDB data layer configuration.
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
```
|
||||
cubdb do
|
||||
directory "/opt/storage/my_awesome_resource"
|
||||
auto_compact? true
|
||||
auto_file_sync? true
|
||||
name :my_awesome_resource
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### Options
|
||||
|
||||
| Name | Type | Default | Docs |
|
||||
|------|------|---------|------|
|
||||
| [`directory`](#cubdb-directory){: #cubdb-directory } | `nil \| String.t` | | The directory within which to store the CubDB data. If none is supplied, then one will be automatically generated in the `priv` directory of the parent OTP application. |
|
||||
| [`otp_app`](#cubdb-otp_app){: #cubdb-otp_app } | `atom` | | The OTP application in whose `priv` directory data should be stored. Only used if `directory` is not supplied. When not provided `Application.get_application/1` will be called for the resource. |
|
||||
| [`auto_compact?`](#cubdb-auto_compact?){: #cubdb-auto_compact? } | `boolean` | `true` | Whether or not to automatically compact the CubDB database. See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-is-compaction) for more information. |
|
||||
| [`auto_file_sync?`](#cubdb-auto_file_sync?){: #cubdb-auto_file_sync? } | `boolean` | `true` | Whether or not to automatically flush the buffer to disk on write. See [the CubDB documentation](https://hexdocs.pm/cubdb/faq.html#what-does-file-sync-mean) |
|
||||
| [`name`](#cubdb-name){: #cubdb-name } | `atom` | | The name of the CubDB database. By default this is the name of the resource module, however in some (rare) circumstances you may wish to specifically name the database. |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>
|
|
@ -173,7 +173,7 @@ defmodule AshCubDB.DataLayer do
|
|||
|
||||
@doc false
|
||||
@impl true
|
||||
def resource_to_query(resource, api), do: %Query{resource: resource, api: api}
|
||||
def resource_to_query(resource, domain), do: %Query{resource: resource, domain: domain}
|
||||
|
||||
@doc false
|
||||
@impl true
|
||||
|
@ -294,16 +294,16 @@ defmodule AshCubDB.DataLayer do
|
|||
stream
|
||||
|> Enum.to_list()
|
||||
|
||||
query.api
|
||||
query.domain
|
||||
|> Runtime.filter_matches(records, query.filter, parent: parent)
|
||||
end
|
||||
|
||||
defp runtime_sort(records, query) when is_list(records) do
|
||||
records =
|
||||
records
|
||||
|> Sort.runtime_sort(query.distinct_sort || query.sort, api: query.api)
|
||||
|> Sort.runtime_distinct(query.distinct, api: query.api)
|
||||
|> Sort.runtime_sort(query.sort, api: query.api)
|
||||
|> Sort.runtime_sort(query.distinct_sort || query.sort, domain: query.domain)
|
||||
|> Sort.runtime_distinct(query.distinct, domain: query.domain)
|
||||
|> Sort.runtime_sort(query.sort, domain: query.domain)
|
||||
|> Enum.drop(query.offset || 0)
|
||||
|> do_limit(query.limit)
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ defmodule AshCubDB.Query do
|
|||
A struct which holds information about a resource query as it is being built.
|
||||
"""
|
||||
|
||||
alias Ash.{Api, Filter, Resource}
|
||||
alias Ash.{Domain, Filter, Resource}
|
||||
|
||||
defstruct aggregates: [],
|
||||
api: nil,
|
||||
domain: nil,
|
||||
calculations: [],
|
||||
distinct: nil,
|
||||
distinct_sort: nil,
|
||||
|
@ -20,7 +20,7 @@ defmodule AshCubDB.Query do
|
|||
|
||||
@type t :: %__MODULE__{
|
||||
aggregates: [Resource.Aggregate.t()],
|
||||
api: Api.t(),
|
||||
domain: Domain.t(),
|
||||
calculations: [Resource.Calculation.t()],
|
||||
distinct: Ash.Sort.t(),
|
||||
distinct_sort: Ash.Sort.t(),
|
||||
|
|
65
mix.exs
65
mix.exs
|
@ -1,7 +1,7 @@
|
|||
defmodule AshCubDB.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
@version "0.4.1"
|
||||
@version "0.5.0-rc.0"
|
||||
|
||||
@moduledoc """
|
||||
A CubDB data layer for `Ash` resources.
|
||||
|
@ -18,8 +18,8 @@ defmodule AshCubDB.MixProject do
|
|||
deps: deps(),
|
||||
description: @moduledoc,
|
||||
package: package(),
|
||||
source_url: "https://code.harton.nz/james/ash_cubdb",
|
||||
homepage_url: "https://code.harton.nz/james/ash_cubdb",
|
||||
source_url: "https://harton.dev/james/ash_cubdb",
|
||||
homepage_url: "https://harton.dev/james/ash_cubdb",
|
||||
aliases: aliases(),
|
||||
dialyzer: [plt_add_apps: [:faker, :smokestack]],
|
||||
docs: [
|
||||
|
@ -28,38 +28,18 @@ defmodule AshCubDB.MixProject do
|
|||
formatters: ["html"],
|
||||
filter_modules: ~r/^Elixir.AshCubDB/,
|
||||
source_url_pattern:
|
||||
"https://code.harton.nz/james/ash_cub_db/src/branch/main/%{path}#L%{line}",
|
||||
spark: [
|
||||
extensions: [
|
||||
%{
|
||||
module: AshCubDB.DataLayer,
|
||||
name: "AshCubDB.DataLayer",
|
||||
target: "Ash.Resource",
|
||||
type: "Ash.DataLayer"
|
||||
}
|
||||
]
|
||||
"https://harton.dev/james/ash_cub_db/src/branch/main/%{path}#L%{line}",
|
||||
extras: [
|
||||
"README.md",
|
||||
"CHANGELOG.md",
|
||||
"documentation/dsls/DSL:-AshCubDB.DataLayer.md"
|
||||
],
|
||||
extras:
|
||||
["README.md"]
|
||||
|> Enum.concat(Path.wildcard("documentation/**/*.{md,livemd,cheatmd}"))
|
||||
|> Enum.map(fn
|
||||
"README.md" -> {:"README.md", title: "Read Me", ash_hq?: false}
|
||||
"documentation/" <> _ = path -> {String.to_atom(path), []}
|
||||
end),
|
||||
groups_for_extras:
|
||||
"documentation/*"
|
||||
|> Path.wildcard()
|
||||
|> Enum.map(fn dir ->
|
||||
name =
|
||||
dir
|
||||
|> Path.split()
|
||||
|> List.last()
|
||||
|> String.split(~r/_+/)
|
||||
|> Enum.map_join(" ", &String.capitalize/1)
|
||||
|
||||
files = dir |> Path.join("**.{md,livemd,cheatmd}") |> Path.wildcard()
|
||||
{name, files}
|
||||
end)
|
||||
groups_for_extras: [
|
||||
Tutorials: ~r'documentation/tutorials',
|
||||
"How To": ~r'documentation/how_to',
|
||||
Topics: ~r'documentation/topics',
|
||||
DSLs: ~r'documentation/dsls'
|
||||
]
|
||||
]
|
||||
]
|
||||
end
|
||||
|
@ -69,7 +49,10 @@ defmodule AshCubDB.MixProject do
|
|||
maintainers: ["James Harton <james@harton.nz>"],
|
||||
licenses: ["HL3-FULL"],
|
||||
links: %{
|
||||
"Source" => "https://code.harton.nz/james/ash_cubdb"
|
||||
"Source" => "https://harton.dev/james/ash_cubdb",
|
||||
"GitHub" => "https://github.com/jimsynz/ash_cubdb",
|
||||
"Changelog" => "https://docs.harton.nz/james/ash_cubdb/changelog.html",
|
||||
"Sponsor" => "https://github.com/sponsors/jimsynz"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
@ -87,19 +70,19 @@ defmodule AshCubDB.MixProject do
|
|||
opts = [only: ~w[dev test]a, runtime: false]
|
||||
|
||||
[
|
||||
{:ash, "~> 2.13"},
|
||||
{:ash, "== 3.0.0-rc.0"},
|
||||
{:cubdb, "~> 2.0"},
|
||||
{:spark, "~> 1.1 and >= 1.1.39"},
|
||||
{:spark, "~> 2.1"},
|
||||
{:earmark, ">= 0.0.0"},
|
||||
{:credo, "~> 1.7", opts},
|
||||
{:dialyxir, "~> 1.3", opts},
|
||||
{:doctor, "~> 0.21", opts},
|
||||
{:earmark, ">= 0.0.0", opts},
|
||||
{:ex_check, "~> 0.15", opts},
|
||||
{:ex_check, "~> 0.16", opts},
|
||||
{:ex_doc, ">= 0.0.0", opts},
|
||||
{:faker, "~> 0.17", opts},
|
||||
{:faker, "~> 0.18", opts},
|
||||
{:git_ops, "~> 2.6", opts},
|
||||
{:mix_audit, "~> 2.1", opts},
|
||||
{:smokestack, "~> 0.4", opts}
|
||||
{:smokestack, "== 0.5.0-rc.0", opts}
|
||||
]
|
||||
end
|
||||
|
||||
|
|
44
mix.lock
44
mix.lock
|
@ -1,36 +1,36 @@
|
|||
%{
|
||||
"ash": {:hex, :ash, "2.15.6", "12cb933372e3d099aeb957701d3315def8691bd7f0db9bf8c3defcb1126c4bff", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: true]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:spark, ">= 1.1.20 and < 2.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e481aab1aa01f46d82f1d910c78839904fbfce985090b2cbec1a758273a7aad4"},
|
||||
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
|
||||
"ash": {:hex, :ash, "3.0.0-rc.0", "5acbfff801258624320dad950b07ea20ac6d8fe06a197d96c806d0bc5567c1b1", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.8", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.7 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e0ff1ba71b7096480da0a1472b95de7b73b88971eeb78a20779ed2bbba532df8"},
|
||||
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
|
||||
"comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},
|
||||
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
|
||||
"credo": {:hex, :credo, "1.7.5", "643213503b1c766ec0496d828c90c424471ea54da77c8a168c725686377b9545", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f799e9b5cd1891577d8c773d245668aa74a2fcd15eb277f51a0131690ebfb3fd"},
|
||||
"cubdb": {:hex, :cubdb, "2.0.2", "d4253885084dae37a8ff73887d232864eb38ecac962aa08543e686b0183a1d62", [:mix], [], "hexpm", "c99cc8f9e6c4deb98d16cca5ded1928edd22e48b4736b76e8a1a85367d7fe921"},
|
||||
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
|
||||
"dialyxir": {:hex, :dialyxir, "1.4.1", "a22ed1e7bd3a3e3f197b68d806ef66acb61ee8f57b3ac85fc5d57354c5482a93", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "84b795d6d7796297cca5a3118444b80c7d94f7ce247d49886e7c291e1ae49801"},
|
||||
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
|
||||
"doctor": {:hex, :doctor, "0.21.0", "20ef89355c67778e206225fe74913e96141c4d001cb04efdeba1a2a9704f1ab5", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "a227831daa79784eb24cdeedfa403c46a4cb7d0eab0e31232ec654314447e4e0"},
|
||||
"earmark": {:hex, :earmark, "1.4.45", "25f0a0fb2a8279a8acfb0a62c45f1d3046e4b35018e728fe6bd15c78f428d7bc", [:mix], [], "hexpm", "3be30a7afe33db742e4682608b90d03c07e944610459394bc75dd617c4f27894"},
|
||||
"earmark_parser": {:hex, :earmark_parser, "1.4.36", "487ea8ef9bdc659f085e6e654f3c3feea1d36ac3943edf9d2ef6c98de9174c13", [:mix], [], "hexpm", "a524e395634bdcf60a616efe77fd79561bec2e930d8b82745df06ab4e844400a"},
|
||||
"ecto": {:hex, :ecto, "3.10.3", "eb2ae2eecd210b4eb8bece1217b297ad4ff824b4384c0e3fdd28aaf96edd6135", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "44bec74e2364d491d70f7e42cd0d690922659d329f6465e89feb8a34e8cd3433"},
|
||||
"elixir_make": {:hex, :elixir_make, "0.7.7", "7128c60c2476019ed978210c245badf08b03dbec4f24d05790ef791da11aa17c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "5bc19fff950fad52bbe5f211b12db9ec82c6b34a9647da0c2224b8b8464c7e6c"},
|
||||
"earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"},
|
||||
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
|
||||
"ecto": {:hex, :ecto, "3.11.2", "e1d26be989db350a633667c5cda9c3d115ae779b66da567c68c80cfb26a8c9ee", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3c38bca2c6f8d8023f2145326cc8a80100c3ffe4dcbd9842ff867f7fc6156c65"},
|
||||
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
|
||||
"ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"},
|
||||
"ex_check": {:hex, :ex_check, "0.15.0", "074b94c02de11c37bba1ca82ae5cc4926e6ccee862e57a485b6ba60fca2d8dc1", [:mix], [], "hexpm", "33848031a0c7e4209c3b4369ce154019788b5219956220c35ca5474299fb6a0e"},
|
||||
"ex_doc": {:hex, :ex_doc, "0.30.6", "5f8b54854b240a2b55c9734c4b1d0dd7bdd41f71a095d42a70445c03cf05a281", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bd48f2ddacf4e482c727f9293d9498e0881597eae6ddc3d9562bd7923375109f"},
|
||||
"faker": {:hex, :faker, "0.17.0", "671019d0652f63aefd8723b72167ecdb284baf7d47ad3a82a15e9b8a6df5d1fa", [:mix], [], "hexpm", "a7d4ad84a93fd25c5f5303510753789fc2433ff241bf3b4144d3f6f291658a6a"},
|
||||
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
|
||||
"ex_check": {:hex, :ex_check, "0.16.0", "07615bef493c5b8d12d5119de3914274277299c6483989e52b0f6b8358a26b5f", [:mix], [], "hexpm", "4d809b72a18d405514dda4809257d8e665ae7cf37a7aee3be6b74a34dec310f5"},
|
||||
"ex_doc": {:hex, :ex_doc, "0.31.2", "8b06d0a5ac69e1a54df35519c951f1f44a7b7ca9a5bb7a260cd8a174d6322ece", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "317346c14febaba9ca40fd97b5b5919f7751fb85d399cc8e7e8872049f37e0af"},
|
||||
"faker": {:hex, :faker, "0.18.0", "943e479319a22ea4e8e39e8e076b81c02827d9302f3d32726c5bf82f430e6e14", [:mix], [], "hexpm", "bfbdd83958d78e2788e99ec9317c4816e651ad05e24cfd1196ce5db5b3e81797"},
|
||||
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
|
||||
"git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"},
|
||||
"git_ops": {:hex, :git_ops, "2.6.0", "e0791ee1cf5db03f2c61b7ebd70e2e95cba2bb9b9793011f26609f22c0900087", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "b98fca849b18aaf490f4ac7d1dd8c6c469b0cc3e6632562d366cab095e666ffe"},
|
||||
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
|
||||
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
|
||||
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
|
||||
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
|
||||
"mix_audit": {:hex, :mix_audit, "2.1.1", "653aa6d8f291fc4b017aa82bdb79a4017903902ebba57960ef199cbbc8c008a1", [:make, :mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.9", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "541990c3ab3a7bb8c4aaa2ce2732a4ae160ad6237e5dcd5ad1564f4f85354db1"},
|
||||
"nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"},
|
||||
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
|
||||
"picosat_elixir": {:hex, :picosat_elixir, "0.2.3", "bf326d0f179fbb3b706bb2c15fbc367dacfa2517157d090fdfc32edae004c597", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f76c9db2dec9d2561ffaa9be35f65403d53e984e8cd99c832383b7ab78c16c66"},
|
||||
"libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"},
|
||||
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
|
||||
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
|
||||
"makeup_erlang": {:hex, :makeup_erlang, "0.1.5", "e0ff5a7c708dda34311f7522a8758e23bfcd7d8d8068dc312b5eb41c6fd76eba", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "94d2e986428585a21516d7d7149781480013c56e30c6a233534bedf38867a59a"},
|
||||
"mix_audit": {:hex, :mix_audit, "2.1.3", "c70983d5cab5dca923f9a6efe559abfb4ec3f8e87762f02bab00fa4106d17eda", [:make, :mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.9", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "8c3987100b23099aea2f2df0af4d296701efd031affb08d0746b2be9e35988ec"},
|
||||
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
|
||||
"reactor": {:hex, :reactor, "0.8.1", "1aec71d16083901277727c8162f6dd0f07e80f5ca98911b6ef4f2c95e6e62758", [:mix], [{:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ae3936d97a3e4a316744f70c77b85345b08b70da334024c26e6b5eb8ede1246b"},
|
||||
"recase": {:hex, :recase, "0.7.0", "3f2f719f0886c7a3b7fe469058ec539cb7bbe0023604ae3bce920e186305e5ae", [:mix], [], "hexpm", "36f5756a9f552f4a94b54a695870e32f4e72d5fad9c25e61bc4a3151c08a4e0c"},
|
||||
"smokestack": {:hex, :smokestack, "0.4.1", "c9f4990b1b7481737d7bb223ebc84d0dde4603d30b9abdcbac9a5193a293cbfb", [:mix], [{:ash, "~> 2.13", [hex: :ash, repo: "hexpm", optional: false]}, {:recase, "~> 0.7", [hex: :recase, repo: "hexpm", optional: false]}, {:spark, ">= 1.1.39 and < 2.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "7c4a7f06d5f9fd30d70dab578045779b9c8c9ce71d7284184cecf64d41ad3413"},
|
||||
"sourceror": {:hex, :sourceror, "0.14.0", "b6b8552d0240400d66b6f107c1bab7ac1726e998efc797f178b7b517e928e314", [:mix], [], "hexpm", "809c71270ad48092d40bbe251a133e49ae229433ce103f762a2373b7a10a8d8b"},
|
||||
"spark": {:hex, :spark, "1.1.40", "b61438fece40eb0ffed7c4c9e5f1c2c817209902ed853b0008b7681b1994c29c", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "40d0f803f1090249ef6a76cb2bf40466c57f4995326dc97996e0b8b4f365ad17"},
|
||||
"smokestack": {:hex, :smokestack, "0.5.0-rc.0", "4ff1474200f5f500e7043c6141d99c6d825c1c935744924fa52a0830c5e02c5f", [:mix], [{:ash, "3.0.0-rc.0", [hex: :ash, repo: "hexpm", optional: false]}, {:recase, "~> 0.7", [hex: :recase, repo: "hexpm", optional: false]}, {:spark, "~> 2.1", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "4f3d61df7859bd2d2e7ba6e2050b92cfd560aa72843eb6e309531fe0bc4bb7a6"},
|
||||
"sourceror": {:hex, :sourceror, "1.0.2", "c5e86fdc14881f797749d1fe5df017ca66727a8146e7ee3e736605a3df78f3e6", [:mix], [], "hexpm", "832335e87d0913658f129d58b2a7dc0490ddd4487b02de6d85bca0169ec2bd79"},
|
||||
"spark": {:hex, :spark, "2.1.7", "72a199e905badb7b43ab6931df1d2c75bc12641fae02ff5e6374033886b07c9b", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "0e4c6879f3f4a6c76fbaae51bc31efb90c48c3267c1f6159b4418df8442c8200"},
|
||||
"splode": {:hex, :splode, "0.2.0", "a1f3b5a8e7c957be495bf0f22dd9e0567a87ec63559963a0ce0c3f0e8dfacedc", [:mix], [], "hexpm", "7cfecc5913ff7feeb04f143e2494cfa7bc6d5bb5bec70f7ffac94c18ea97f303"},
|
||||
"stream_data": {:hex, :stream_data, "0.6.0", "e87a9a79d7ec23d10ff83eb025141ef4915eeb09d4491f79e52f2562b73e5f47", [:mix], [], "hexpm", "b92b5031b650ca480ced047578f1d57ea6dd563f5b57464ad274718c9c29501c"},
|
||||
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
|
||||
"typable": {:hex, :typable, "0.3.0", "0431e121d124cd26f312123e313d2689b9a5322b15add65d424c07779eaa3ca1", [:mix], [], "hexpm", "880a0797752da1a4c508ac48f94711e04c86156f498065a83d160eef945858f8"},
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
use ExUnit.Case, async: true
|
||||
alias Ash.{Error.Query.NotFound, Query}
|
||||
alias AshCubDB.Info
|
||||
alias Support.{Api, Author, Post}
|
||||
alias Support.{Author, Domain, Post}
|
||||
import Support.Factory
|
||||
require Query
|
||||
|
||||
|
@ -105,7 +105,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
insert!(Author, count: 3)
|
||||
|
||||
expected =
|
||||
Author
|
||||
Post
|
||||
|> params!(count: 3)
|
||||
|> Enum.map(&Post.create!(&1, tenant: :wat))
|
||||
|
||||
|
@ -124,7 +124,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
[actual] =
|
||||
Author
|
||||
|> Query.filter(name: "Marty McFly")
|
||||
|> Api.read!()
|
||||
|> Domain.read!()
|
||||
|
||||
assert expected.id == actual.id
|
||||
end
|
||||
|
@ -137,7 +137,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
sorted =
|
||||
Author
|
||||
|> Query.sort(name: :desc)
|
||||
|> Api.read!()
|
||||
|> Domain.read!()
|
||||
|
||||
assert Enum.map(sorted, &to_string(&1.name)) == ["Mallory", "Bob", "Alice"]
|
||||
end
|
||||
|
@ -148,7 +148,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
assert [_] =
|
||||
Author
|
||||
|> Query.limit(1)
|
||||
|> Api.read!()
|
||||
|> Domain.read!()
|
||||
end
|
||||
|
||||
test "offset" do
|
||||
|
@ -157,7 +157,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
assert [_, _] =
|
||||
Author
|
||||
|> Query.offset(1)
|
||||
|> Api.read!()
|
||||
|> Domain.read!()
|
||||
end
|
||||
|
||||
test "distinct" do
|
||||
|
@ -167,7 +167,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
assert [selected] =
|
||||
Author
|
||||
|> Query.distinct(:name)
|
||||
|> Api.read!()
|
||||
|> Domain.read!()
|
||||
|
||||
assert selected.name == author.name
|
||||
end
|
||||
|
@ -181,7 +181,7 @@ defmodule AshCubDB.DataLayerTest do
|
|||
Post
|
||||
|> Query.distinct(:title)
|
||||
|> Query.distinct_sort(body: :desc)
|
||||
|> Api.read!()
|
||||
|> Domain.read!()
|
||||
|
||||
assert selected.title == post.title
|
||||
assert selected.body == "Mallory is cool"
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
defmodule Support.Api do
|
||||
@moduledoc false
|
||||
use Ash.Api
|
||||
|
||||
resources do
|
||||
resource(Support.Author)
|
||||
resource(Support.Post)
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
defmodule Support.Author do
|
||||
@moduledoc false
|
||||
use Ash.Resource, data_layer: AshCubDB.DataLayer
|
||||
use Ash.Resource, data_layer: AshCubDB.DataLayer, domain: Support.Domain
|
||||
|
||||
cubdb do
|
||||
otp_app :ash_cubdb
|
||||
|
@ -14,7 +14,7 @@ defmodule Support.Author do
|
|||
attributes do
|
||||
uuid_primary_key :id
|
||||
|
||||
attribute :name, :ci_string
|
||||
attribute :name, :ci_string, public?: true
|
||||
end
|
||||
|
||||
relationships do
|
||||
|
@ -22,12 +22,11 @@ defmodule Support.Author do
|
|||
end
|
||||
|
||||
actions do
|
||||
default_accept :*
|
||||
defaults ~w[create read]a
|
||||
end
|
||||
|
||||
code_interface do
|
||||
define_for Support.Api
|
||||
|
||||
define :create
|
||||
define :read
|
||||
end
|
||||
|
|
9
test/support/domain.ex
Normal file
9
test/support/domain.ex
Normal file
|
@ -0,0 +1,9 @@
|
|||
defmodule Support.Domain do
|
||||
@moduledoc false
|
||||
use Ash.Domain
|
||||
|
||||
resources do
|
||||
resource Support.Author
|
||||
resource Support.Post
|
||||
end
|
||||
end
|
|
@ -1,21 +1,19 @@
|
|||
defmodule Support.Post do
|
||||
@moduledoc false
|
||||
use Ash.Resource, data_layer: AshCubDB.DataLayer
|
||||
use Ash.Resource, data_layer: AshCubDB.DataLayer, domain: Support.Domain
|
||||
|
||||
cubdb do
|
||||
otp_app :ash_cubdb
|
||||
end
|
||||
|
||||
attributes do
|
||||
uuid_primary_key :id do
|
||||
writable? true
|
||||
end
|
||||
|
||||
attribute :title, :string
|
||||
attribute :body, :string
|
||||
uuid_primary_key :id, writable?: true, public?: true
|
||||
attribute :title, :string, public?: true
|
||||
attribute :body, :string, public?: true
|
||||
end
|
||||
|
||||
actions do
|
||||
default_accept [:id, :title, :body]
|
||||
defaults ~w[create read update destroy]a
|
||||
end
|
||||
|
||||
|
@ -28,8 +26,6 @@ defmodule Support.Post do
|
|||
end
|
||||
|
||||
code_interface do
|
||||
define_for Support.Api
|
||||
|
||||
define :create
|
||||
define :read
|
||||
define :update
|
||||
|
|
Loading…
Reference in a new issue