Skip to content

Commit e0aeac8

Browse files
authored
Merge pull request #37 from eaf-andrewbaccus/patch-1
Update README.md With Username/PWD Example
2 parents 47bbb6e + 4f3151a commit e0aeac8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ cursor
7373
|> IO.inspect
7474
```
7575

76+
To specify a username and password, use the `:username`, `:password`, and `:auth_source` options.
77+
78+
```elixir
79+
# Starts an unpooled connection
80+
{:ok, conn} =
81+
Mongo.start_link(url: "mongodb://localhost:27017/db-name",
82+
username: "test_user",
83+
password: "hunter2",
84+
auth_source: "admin_test")
85+
86+
# Gets an enumerable cursor for the results
87+
cursor = Mongo.find(conn, "test-collection", %{})
88+
89+
cursor
90+
|> Enum.to_list()
91+
|> IO.inspect
92+
```
93+
94+
For secure requests, you may need to add some more options; see the "AWS, TLS and Erlang SSL ciphers" section below.
95+
7696
### Connection pooling
7797
The driver supports pooling by DBConnection (2.x). By default `mongodb_driver` will start a single
7898
connection, but it also supports pooling with the `:pool_size` option. For 3 connections add the `pool_size: 3` option to `Mongo.start_link` and to all

0 commit comments

Comments
 (0)