Skip to content

Commit 55dcdfd

Browse files
authored
Merge pull request #51 from p-mongo/readme-insert
Add simple insert examples to the readme
2 parents 2071ce5 + 6b03e4b commit 55dcdfd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ For more information see
199199

200200
* [Mongo.watch_collection](https://hexdocs.pm/mongodb_driver/Mongo.html#watch_collection/5)
201201

202+
### Inserts
203+
204+
To insert a single document:
205+
206+
```elixir
207+
Mongo.insert_one(top, "users", %{first_name: "John", last_name: "Smith"})
208+
```
209+
210+
To insert a list of documents:
211+
212+
```elixir
213+
Mongo.insert_many(top, "users", [
214+
%{first_name: "John", last_name: "Smith"},
215+
%{first_name: "Jane", last_name: "Doe"}
216+
])
217+
```
202218

203219
### Bulk writes
204220

0 commit comments

Comments
 (0)