You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-2Lines changed: 44 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -214,6 +214,10 @@ While using the `Mongo.Encoder` protocol give you the possibility to encode your
214
214
- support for id generation
215
215
- support for default values
216
216
- support for derived values
217
+
- support for alias attribute names
218
+
219
+
But in the case of queries and updates, a rewrite of the attribute names does not take place. It is still up to you
220
+
to use the correct attribute names.
217
221
218
222
When using the MongoDB driver only maps and keyword lists are used to represent documents.
219
223
If you prefer to use structs instead of the maps to give the document a stronger meaning or to emphasize
@@ -313,11 +317,18 @@ iex(3)> Label.load(m, true)
313
317
```
314
318
315
319
The background is that MongoDB always returns binarys as keys and structs use atoms as keys.
316
-
317
320
For more information look at the module documentation `Mongo.Collection`.
318
-
319
321
Of course, using the `Mongo.Collection` is not free. When loading and saving, the maps are converted into structures, which increases CPU usage somewhat. When it comes to speed, it is better to use the maps directly.
320
322
323
+
## Breaking changes
324
+
325
+
Prior to version 0.9.2 the dump function returns atoms as key. Since the dump function is the inverse function of load,
326
+
which uses binary keys as default, the dump function should return binary keys as well. This increases the consistency and
327
+
you can do:
328
+
329
+
l =Label.load(doc)
330
+
doc =Label.dump(l)
331
+
assert l ==Label.load(doc)
321
332
322
333
## Using the Repo Module
323
334
@@ -358,6 +369,35 @@ In addition, the convenient configuration, the `Mongo.Repo` module will also inc
358
369
359
370
For more information check out the `Mongo.Repo` module documentation and the `Mongo` module documentation.
360
371
372
+
## Breaking changes
373
+
374
+
Prior to version 0.9.2 some Repo functions use the dump function for the query parameter. This worked only
375
+
for some query that used only the attributes of the document. In the case of nested documents, it didn't work, so
376
+
it is changed to be more consistent. The Repo module is very simple without any query rewriting like Ecto does. In the case
377
+
you want to use the `:name` option, you need to specify the query and updates in the Repo following
378
+
the specification in the MongoDB. Example:
379
+
380
+
defmodule MyApp.Session do
381
+
@moduledoc false
382
+
use Mongo.Collection
383
+
384
+
alias BSON.Binary
385
+
386
+
collection :s do
387
+
attribute :uuid, Binary.t(), name: :u
388
+
end
389
+
end
390
+
391
+
If you use the Repo module and want to fetch a specific session document, this won't work
0 commit comments