Skip to content

Commit d1ee4be

Browse files
committed
Add code formatting
1 parent eee921d commit d1ee4be

16 files changed

+920
-626
lines changed

.formatter.exs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
3+
]

README.md

+28-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
Ecto 2.x adapter for [ArangoDB](https://www.arangodb.com/).
44

5+
The aim for this adapter is for it to be a drop-in replacement for the default
6+
Postgres adapter.
7+
58
It converts `Ecto.Query` structs to [AQL](https://docs.arangodb.com/3.1/AQL).
6-
At the moment the `from`, `where`, `order_by`, `limit`
7-
`offset` and `select` clauses are supported.
9+
10+
At the moment the `from`, `where`, `order_by`, `limit`,
11+
`offset`, `select` and `preload` clauses are supported.
812

913
For example, this Ecto query:
1014
```elixir
@@ -22,7 +26,8 @@ FOR u0 IN `users`
2226
LIMIT 10
2327
RETURN { `name`: u0.`name`, `age`: u0.`age` }
2428
```
25-
29+
30+
2631
## Usage
2732

2833
In the repository configuration, you need to specify the `:adapter`:
@@ -33,9 +38,9 @@ config :my_app, MyApp.Repo,
3338
database: "my_app"
3439
...
3540
```
36-
41+
3742
The following options can be defined to configure the connection to ArangoDB.
38-
Unless specified otherwise, the show default values are used.
43+
Unless specified otherwise, the shown default values are used.
3944
```elixir
4045
host: "localhost",
4146
port: 8529,
@@ -81,26 +86,42 @@ defmodule Post do
8186
end
8287
```
8388

89+
8490
## Installation
8591

86-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
87-
by adding `arangodb_ecto` to your list of dependencies in `mix.exs`:
92+
The package can be installed by adding `arangodb_ecto` to your list of dependencies in `mix.exs`:
8893

8994
```elixir
9095
def deps do
9196
[{:arangodb_ecto, "~> 0.1.0"}]
9297
end
9398
```
9499

100+
To use the latest version, available on github:
101+
102+
```elixir
103+
def deps do
104+
[{:arangodb_ecto, git: "https://github.com/ArangoDB-Community/arangodb_ecto.git"},
105+
end
106+
```
107+
95108
## Features not yet implemented
96109
* subqueries
97110
* joins
98111
* on conflict
99112
* upserts
100113

114+
101115
## Testing
116+
102117
Before running the tests, configure access to your Arango database by setting
103118
these environment variables:
104119
- `ARANGO_SRV`
105120
- `ARANGO_USR`
106121
- `ARANGO_PWD`
122+
123+
More conveniently, you can start an unauthenticated Docker instance of ArangoDB
124+
with
125+
```
126+
docker run --publish 8529:8529 --env ARANGO_NO_AUTH=1 arangodb/arangodb
127+
```

lib/arangodb_ecto.ex

+16-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ defmodule ArangoDB.Ecto do
99
alias ArangoDB.Ecto.Utils
1010

1111
def truncate(repo, coll) do
12-
result = Utils.get_endpoint(repo)
12+
result =
13+
Utils.get_endpoint(repo)
1314
|> Arangoex.Collection.truncate(%Arangoex.Collection{name: coll})
15+
1416
case result do
1517
{:ok, _} -> :ok
1618
{:error, _} -> result
@@ -33,12 +35,21 @@ defmodule ArangoDB.Ecto do
3335
defdelegate delete(repo, schema_meta, filters, options), to: ArangoDB.Ecto.Adapter
3436
defdelegate dumpers(primitive_type, ecto_type), to: ArangoDB.Ecto.Adapter
3537
defdelegate ensure_all_started(repo, type), to: ArangoDB.Ecto.Adapter
36-
defdelegate execute(repo, query_meta, query, params, process, options), to: ArangoDB.Ecto.Adapter
37-
defdelegate insert(repo, schema_meta, fields, on_conflict, returning, options), to: ArangoDB.Ecto.Adapter
38-
defdelegate insert_all(repo, schema_meta, header, list, on_conflict, returning, options), to: ArangoDB.Ecto.Adapter
38+
39+
defdelegate execute(repo, query_meta, query, params, process, options),
40+
to: ArangoDB.Ecto.Adapter
41+
42+
defdelegate insert(repo, schema_meta, fields, on_conflict, returning, options),
43+
to: ArangoDB.Ecto.Adapter
44+
45+
defdelegate insert_all(repo, schema_meta, header, list, on_conflict, returning, options),
46+
to: ArangoDB.Ecto.Adapter
47+
3948
defdelegate loaders(primitive_type, ecto_type), to: ArangoDB.Ecto.Adapter
4049
defdelegate prepare(atom, query), to: ArangoDB.Ecto.Adapter
41-
defdelegate update(repo, schema_meta, fields, filters, returning, options), to: ArangoDB.Ecto.Adapter
50+
51+
defdelegate update(repo, schema_meta, fields, filters, returning, options),
52+
to: ArangoDB.Ecto.Adapter
4253

4354
@behaviour Ecto.Adapter.Migration
4455

0 commit comments

Comments
 (0)