Skip to content

Commit

Permalink
Add directions for using with MongoDB Ecto
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmessinger committed Jun 8, 2022
1 parent 6ae2049 commit f3be495
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ Mongo.find(:mongo, "collection", %{}, limit: 20)

More pool options in [here](https://hexdocs.pm/db_connection/2.0.6/DBConnection.html#start_link/2-options).


### Using with MongoDB Ecto

If you're using Mongo with the MongoDB Ecto library, where you have it defined in your config/runtime.exs like this:

```elixir
config :my_app, MyApp.Repo,
url: "mongo connection url"
```

You'll want to do reference mongo like this:

```elixir
Mongo.find(MyApp.Repo.pool(), collection, %{_id: %{"$in" =>"some_ids"}})
```

### Replica Sets

To connect to a MongoDB cluster that is using replica sets, it is recommended to
Expand Down

0 comments on commit f3be495

Please sign in to comment.