Skip to content

Commit 529b63d

Browse files
authored
Merge pull request #4 from pinx/master
Allow `database` in config, instead of `database_name`
2 parents def02c6 + ccdb8ff commit 529b63d

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In the repository configuration, you need to specify the `:adapter`:
3030
```elixir
3131
config :my_app, MyApp.Repo,
3232
adapter: ArangoDB.Ecto,
33-
database_name: "my_app"
33+
database: "my_app"
3434
...
3535
```
3636

@@ -40,7 +40,7 @@ Unless specified otherwise, the show default values are used.
4040
host: "localhost",
4141
port: 8529,
4242
scheme: "http",
43-
database_name: "_system",
43+
database: "_system",
4444
arrango_version: 30_000,
4545
headers: %{"Accept": "*/*"},
4646
use_auth: :basic,
@@ -75,6 +75,7 @@ defmodule Post do
7575
end
7676
end
7777
```
78+
7879
## Installation
7980

8081
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
@@ -92,7 +93,9 @@ end
9293
* on conflict
9394
* upserts
9495

95-
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
96-
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
97-
be found at [https://hexdocs.pm/arangodb_ecto](https://hexdocs.pm/arangodb_ecto).
98-
96+
## Testing
97+
Before running the tests, configure access to your Arango database by setting
98+
these environment variables:
99+
- `ARANGO_SRV`
100+
- `ARANGO_USR`
101+
- `ARANGO_PWD`

lib/arangodb_ecto/utils.ex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ defmodule ArangoDB.Ecto.Utils do
33

44
@spec get_endpoint(Ecto.Adapter.repo, String.t | nil) :: Arangoex.Endpoint.t
55
def get_endpoint(repo, prefix \\ nil) do
6-
config = repo.config
7-
config = if prefix == nil,
8-
do: config,
9-
else: Keyword.put(config, :database_name, prefix)
10-
6+
config = repo.config()
7+
database = prefix || Keyword.get(config, :database) || Keyword.get(config, :database_name)
8+
config =
9+
config
10+
|> Keyword.put(:database_name, database)
11+
1112
struct(Arangoex.Endpoint, config)
1213
end
13-
end
14+
end

test/test_helper.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ alias Ecto.Integration.TestRepo
1212

1313
Application.put_env(:ecto, TestRepo,
1414
adapter: ArangoDB.Ecto,
15-
database_name: "test")
15+
database: "test")
1616

1717
defmodule Ecto.Integration.TestRepo do
1818
use Ecto.Integration.Repo, otp_app: :ecto
@@ -74,4 +74,4 @@ _ = ArangoDB.Ecto.storage_down(PoolRepo.config)
7474
:ok = Ecto.Migrator.up(PoolRepo, 0, Ecto.Integration.Migration, log: false)
7575

7676

77-
Process.flag(:trap_exit, true)
77+
Process.flag(:trap_exit, true)

0 commit comments

Comments
 (0)