Skip to content

Commit 498eac3

Browse files
committed
ecto_repos config example
1 parent e2f0bbe commit 498eac3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ or check out examples below.
1919
# In your config/config.exs file
2020
config :my_app, Repo,
2121
adapter: Mongo.Ecto,
22+
# Example key-value configuration:
2223
database: "ecto_simple",
2324
username: "mongodb",
2425
password: "mongodb",
2526
hostname: "localhost"
26-
# Or you can use a connection string (mongodb:// or mongodb+srv://), e.g.:
27-
# mongo_url: "mongodb://mongodb:mongodb@localhost:27017/ecto_simple"
27+
# OR you can configure with a connection string (mongodb:// or mongodb+srv://):
28+
mongo_url: "mongodb://mongodb:mongodb@localhost:27017/ecto_simple"
29+
30+
config :my_app,
31+
# Add Repo to this list so you can run commands like `mix ecto.create`.
32+
ecto_repos: [Repo]
2833

2934
# In your application code
3035
defmodule Repo do

lib/mongo_ecto.ex

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ defmodule Mongo.Ecto do
2828
password: "mongodb",
2929
hostname: "localhost"
3030
31+
config :my_app,
32+
# Add Repo to this list so you can run commands like `mix ecto.create`.
33+
ecto_repos: [Repo]
34+
3135
For more connection options, see mongodb-driver's [Mongo.start_link](https://hexdocs.pm/mongodb_driver/1.5.2/Mongo.html#start_link/1). Note that to use a connection string (mongodb:// or mongodb+srv://), you must set `mongo_url: ` instead of `url: `.
3236
3337
Each repository in Ecto defines a `start_link/0` function that needs to be

0 commit comments

Comments
 (0)