Skip to content

Commit 7df3128

Browse files
committed
fixed some typos
1 parent b43ee0f commit 7df3128

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ it will be written to database, as:
9393
}
9494
```
9595

96-
## Collections
96+
### Collections
9797

9898
While using the `Mongo.Encoder` protocol give you the possibility to encode your structs into maps the opposite way to decode those maps into structs is missing. To handle it you can use the `Mongo.Collection` which provides some boilerplate code for a better support of structs while using the MongoDB driver
9999

@@ -123,9 +123,7 @@ iex> label = %Label{name: label_map["name"], color: label_map["color"]}
123123

124124
We have defined a module `Label` as `defstruct`, then we get the first label document
125125
the collection `labels`. The function `find_one` returns a map. We convert the map manually and
126-
get the desired struct.
127-
128-
If we want to save a new structure, we have to do the reverse. We convert the struct into a map:
126+
get the desired struct. If we want to save a new structure, we have to do the reverse. We convert the struct into a map:
129127

130128
```elixir
131129
iex> label = %Label{}
@@ -134,7 +132,7 @@ iex> {:ok, _} = Mongo.insert_one(:mongo, "labels", label_map)
134132
```
135133

136134
Alternatively, you can also remove the `__struct__` key from `label`. The MongoDB driver automatically
137-
converts the atom keys into strings.
135+
converts the atom keys into strings (Or use the `Mongo.Encode` protocol)
138136

139137
```elixir
140138
iex> Map.drop(label, [:__struct__])
@@ -150,7 +148,7 @@ convert manually, too. If you take a closer look at the necessary work, two basi
150148

151149
```elixir
152150
defmodule Label do
153-
use Collection
151+
use Mongo.Collection
154152

155153
document do
156154
attribute :name, String.t(), default: "warning"
@@ -163,7 +161,7 @@ This results in the following module:
163161
```elixir
164162
defmodule Label do
165163

166-
defstruct [name: "warning", color: "red"]
164+
defstruct [name: "warning", color: "red"]X
167165

168166
@type t() :: %Label{String.t(), String.t()}
169167

0 commit comments

Comments
 (0)